フラグメントを使用した下部ナビゲーションAndroidの例

下部ナビゲーションバーは常にアプリケーションの下部にあります.
下部ナビゲーションAndroidの例、
Androidでのボトムナビゲーションの使用 code:
<?xml version=”1.0″ encoding=”utf-8″?><resources> <color name=”colorPrimary”>#278be3</color> <color name=”colorPrimaryDark”>#0f5998</color> <color name=”colorAccent”>#4075a2</color> <color name=”colorNavIcon”>#dae9f6</color> <color name=”colorNavText”>#01294b</color></resources>
フラグメントの作成
import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup; /** * Created by Belal on 1/23/2018. */ public class HomeFragment extends Fragment
{ @Nullable@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{ //just change the fragment_dashboard//with the fragment you want to inflate//like if the class is HomeFragment it should have R.layout.home_fragment//if it is DashboardFragment it should have R.layout.fragment_dashboardreturn inflater.inflate(R.layout.fragment_home, null);
}}
フラグメントの切り替え
private boolean loadFragment(Fragment fragment) { //switching fragment if (fragment != null) { getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, fragment) .commit(); returntrue; } returnfalse; }
下部ナビゲーションはユーザーフレンドリーなアプリケーションを作成