item-设置可见性
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                item-设置可见性
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.                        
                                如果我們想要設置menu中item的可見行,有兩種方式:
1.直接在menu的xml代碼中設置
<menu> <item android:id="@+id/action_hotknot"android:showAsAction="always"android:icon="@drawable/action_mode_hotknot"android:title="@string/hotknot" < !--可見性設置-- android:visible="true" /> </menu>2.在代碼中設置
它跟控件設置可見行不一樣,控件設置的是
TextView tv = new TextView(this);tv.setVisibility(View.GONE);而menu中設置為
@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu);MenuItem mItem;mItem = menu.getItem(R.id.action_settings);mItem.setVisible(false);return true;}?
轉載于:https://www.cnblogs.com/zhangshuli-1989/p/zhangshuli_menuitem_150324141.html
總結
以上是生活随笔為你收集整理的item-设置可见性的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 交通银行“想分就分”是什么意思?办理有什
 - 下一篇: 招商银行信用卡e分期怎么提前还款?剩余手