資源描述:
《android實現(xiàn)底部菜單欄》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、android實現(xiàn)底部菜單欄android程序,許多時候需要菜單欄顯示在底部或頂部,但是沒有很好的組建供程序員調(diào)用,過自定義了一個視圖,用來實現(xiàn)底部菜單欄,效果如下圖:實現(xiàn)的主要代碼:Java代碼?1.@Override???2.????public?void?onCreate(Bundle?savedInstanceState)?{???3.????????super.onCreate(savedInstanceState);???4.????????requestWindowFeature(Window.
2、FEATURE_NO_TITLE);???5.????????setContentView(R.layout.main);???6.??7.????????linearLayout?=?(LinearLayout)?findViewById(R.id.home);???8.????????linearLayout.setOnClickListener(new?OnClickListener()?{???9.????????????@Override???10.????????????public?void?o
3、nClick(View?v)?{???11.????????????????linearLayout???12.????????????????????????.setBackgroundResource(R.drawable.tab_two_highlight);???13.????????????????publish.setBackgroundResource(R.drawable.tab_one_normal);???14.????????????????change.setBackgroundRes
4、ource(R.drawable.tab_one_normal);???15.????????????????more.setBackgroundResource(R.drawable.tab_one_normal);???16.????????????}???17.????????});???1.????????linearLayout???2.????????.setBackgroundResource(R.drawable.tab_two_highlight);???3.??4.????????publ
5、ish?=?(LinearLayout)?findViewById(R.id.publish);???5.????????publish.setOnClickListener(new?OnClickListener()?{???6.????????????@Override???7.????????????public?void?onClick(View?v)?{???8.????????????????publish.setBackgroundResource(R.drawable.tab_two_high
6、light);???9.????????????????linearLayout.setBackgroundResource(R.drawable.tab_one_normal);???10.????????????????change.setBackgroundResource(R.drawable.tab_one_normal);???11.????????????????more.setBackgroundResource(R.drawable.tab_one_normal);???12.???????
7、?????}???13.????????});???14.??15.????????change?=?(LinearLayout)?findViewById(R.id.change);???16.????????change.setOnClickListener(new?OnClickListener()?{???17.????????????@Override???18.????????????public?void?onClick(View?v)?{???19.????????????????change
8、.setBackgroundResource(R.drawable.tab_two_highlight);???20.????????????????linearLayout.setBackgroundResource(R.drawable.tab_one_normal);???21.????????????????publish.setBackgroundResource(R.drawable.t