<menu> <item1/> <item2 <relativeLayout> <TextVIEw1/> <TextVIEw2/> <relativeLayout> /></menu>
这可以在Layout XML中完成,还是以编程方式完成?如果没有,解决方案会有所帮助.谢谢.
解决方法 使用您想要的视图创建布局文件,然后像这样使用它 –<item androID:ID="@+ID/menu_refresh" androID:title="@string/refresh" yourapp:showAsAction="never" androID:actionLayout="@layout/my_custom_layout"/>
要编辑文本视图 –
@OverrIDepublic boolean onPrepareOptionsMenu(Menu menu) { //Get a reference to your item by ID MenuItem item = menu.findItem(R.ID.menu_refresh); //Here,you get access to the vIEw of your item,in this case,the layout of the item has a relativeLayout as root vIEw but you can change it to whatever you use relativeLayout rootVIEw = (relativeLayout)item.getActionVIEw(); //Then you access to your control by finding it in the rootVIEw TextVIEw textvIEw1 = (TextVIEw) rootVIEw.findVIEwByID(R.ID.text1); //And from here you can do whatever you want with your text vIEw return true;}@H_502_33@ 总结
以上是内存溢出为你收集整理的如何将RelativeLayout添加为菜单项 – Android全部内容,希望文章能够帮你解决如何将RelativeLayout添加为菜单项 – Android所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)