我创建包含三个项目的菜单文件。操作栏中的菜单仅显示三个项目,但在同一页面上的移动菜单按钮(硬件按钮)上显示相同的项目两次。我使用了menu.clear()但它没有用。如果有任何解决方案请建议我。我附上了问题的代码。请回复我。提前谢谢。
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.ticket_webview);
Intent intent = getIntent(); // get data from previous activity
Ticket_hash=intent.getStringExtra("Ticket_hash");
Ticket_title=intent.getStringExtra("title");
ID=intent.getStringExtra("ID");
filter_id=intent.getStringExtra("filter_id");
is_queue_set=intent.getStringExtra("set_queue");
if(is_queue_set!="Null" || is_queue_set!="")
{
SET_QUEUE=is_queue_set;
}
else
{
SET_QUEUE="";
}
webview =(WebView)findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
//webview.getSettings().setPluginsEnabled(true);//THIS ONE COMMENTED Instead of the setPluginsEnabled there will be new method setPluginState,
//setPluginsEnabled is removed in the api level 18
webview.getSettings().setPluginState(PluginState.ON);
new ticketPost().execute(); // parse data from json file using Asynctask
}
// ********
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
menu.clear();//To eleminate duplicate menubar at the bottom
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.ticket_properties_menu, menu);
return super.onCreateOptionsMenu(menu);
}
@覆盖 public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId())
{
case R.id.menu_add_note:
Intent i3 = new Intent(Ticket_posts.this,Add_note.class);
startActivity(i3);
return true;
case R.id.menu_send_reply:
Intent reply= new Intent(Ticket_posts.this,Send_reply.class);
startActivity(reply);
return true;
case R.id.menu_pin:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
// Ticket_properties_menu.xml
<item android:id="@+id/menu_pin"
android:icon="@drawable/pin"
android:title="@string/pin"
android:showAsAction="never"
/>
<item android:id="@+id/menu_send_reply"
android:icon="@drawable/send"
android:title="@string/send_reply"
android:showAsAction="never"
/>
<item android:id="@+id/menu_add_note"
android:icon="@drawable/add_note"
android:title="@string/add_note"
android:showAsAction="never"
/>