<?xml version="1.0" enCoding="utf-8"?><menu xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto"> <item androID:ID="@+ID/action_name" androID:icon="@drawable/you_resource_here" androID:title="Text to be seen by user" app:showAsAction="always" androID:orderIncategory="0"/></menu>
然后在你的活动中,如果你创建了一个新的文件,你需要编辑onCreateOptionsMenu
@OverrIDepublic boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main,menu); return true;}
您可以编辑以下方法执行的 *** 作:
@OverrIDepublic boolean onoptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button,so long // as you specify a parent activity in AndroIDManifest.xml. int ID = item.getItemID(); //noinspection SimplifiableIfStatement if (ID == R.ID.action_name) { return true; } return super.onoptionsItemSelected(item);}总结
以上是内存溢出为你收集整理的android – 在 *** 作栏的右上角添加一个按钮全部内容,希望文章能够帮你解决android – 在 *** 作栏的右上角添加一个按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)