我创建包含三个项目的菜单文件 . 操作栏中的菜单仅显示三个项目,但在同一页面上的移动菜单按钮(硬件按钮)上显示相同的项目两次 . 我使用了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);
}
@Override 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
android:icon="@drawable/pin"
android:title="@string/pin"
android:showAsAction="never"
/>
android:icon="@drawable/send"
android:title="@string/send_reply"
android:showAsAction="never"
/>
android:icon="@drawable/add_note"
android:title="@string/add_note"
android:showAsAction="never"
/>