Problem: Layout
Control Bottomlayout to three ImageButton below
Intent: The three buttons below are implemented as moments and only one is selected (similar to Weibo)
The simplest solution:
1 PackageCom.example.weibo;2 3 ImportAndroid.content.Context;4 ImportAndroid.util.AttributeSet;5 ImportAndroid.view.LayoutInflater;6 ImportAndroid.view.View;7 ImportAndroid.widget.ImageButton;8 Importandroid.widget.LinearLayout;9 Ten One Public classBottomlayoutextendsLinearLayout { A PrivateImageButton main; - PrivateImageButton add; - PrivateImageButton account; the - Final intHome_b =R.DRAWABLE.IC_HOME_BLACK_48DP; - Final intHome_g =R.DRAWABLE.IC_HOME_GREY600_48DP; - Final intAdd_b =R.DRAWABLE.IC_ADD_CIRCLE_BLACK_48DP; + Final intAdd_g =R.DRAWABLE.IC_ADD_CIRCLE_GREY600_48DP; - Final intAccount_b =R.DRAWABLE.IC_ACCOUNT_BOX_BLACK_48DP; + Final intAccount_g =R.DRAWABLE.IC_ACCOUNT_BOX_GREY600_48DP; A at Publicbottomlayout (Context context,attributeset attrs) { - Super(context,attrs); -Layoutinflater.from (context). Inflate (R.layout.bottom, This); -Main =(ImageButton) Findviewbyid (r.id.bottom_main); -Add =(ImageButton) Findviewbyid (r.id.bottom_add); -Account =(ImageButton) Findviewbyid (r.id.bottom_account); inMain.settag ("G"); -Add.settag ("G"); toAccount.settag ("G"); + - the * $Main.setonclicklistener (NewOnclicklistener () {Panax Notoginseng @Override - Public voidOnClick (View v) { the if(V.gettag () = = "G") + { A ( (ImageButton) v). Setimageresource (Home_b); theV.settag ("B"); + Add.setimageresource (add_g); -Add.settag ("G"); $ Account.setimageresource (account_g); $Account.settag ("G"); - } - } the }); -Add.setonclicklistener (NewOnclicklistener () {Wuyi @Override the Public voidOnClick (View v) { - if(V.gettag () = = "G") Wu { - ( (ImageButton) v). Setimageresource (add_b); AboutV.settag ("B"); $ Main.setimageresource (home_g); -Main.settag ("G"); - Account.setimageresource (account_g); -Account.settag ("G"); A } + } the }); -Account.setonclicklistener (NewOnclicklistener () { $ @Override the Public voidOnClick (View v) { the if(V.gettag () = = "G") the { the ( (ImageButton) v). Setimageresource (account_b); -V.settag ("B"); in Add.setimageresource (add_g); theAdd.settag ("G"); the Main.setimageresource (home_g); AboutMain.settag ("G"); the } the } the }); + - } the}View Code
Results
But it doesn't seem to mean anything, so tomorrow we'll see if there's any good plan.
How do you implement a conjugate between buttons in a custom control?