Duplicate menu item when app crash on home screen

267 views Asked by At

Well, i used App Compact Actionbar with ActionBarActivity. when app crash, app will restart again and i got duplicate menu item on App Home Screen . i don't know why its crash. Can anybody please answer my. i hope i'll get the result.

Here is Optionmenu XML.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.demo.MainActivity" >

<item
    android:id="@+id/action_cart"
    android:icon="@drawable/action_cart_hover"
    android:title="@string/action_cart"
    app:actionLayout="@layout/item_actionbar_cart_count"
    app:showAsAction="always"/>

Thanks in advance.

1

There are 1 answers

6
Blaze Tama On BEST ANSWER

I dont know what happened when your apps crashing (a logcat will be helpful), but try to call clear method :

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear(); //call the clear method
    inflater.inflate(R.menu.signin, menu);
    super.onCreateOptionsMenu(menu, inflater);
}