2014-11-06 6 views
28

मैं अपने लेआउट में एक v7 टूलबार शामिल करता हूं।आप नए लॉलीपॉप टूलबार से एक फुलाए गए मेनू/आइटम को कैसे हटाते हैं?

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/white" 
    /> 

मैं पालन करते हुए उसे में एक मेनू बढ़ा-चढ़ाकर हूँ:

mToolbar.inflateMenu(R.menu.options_add_contact); 

अब मैं कैसे को दूर पता है/इसे रीसेट? मैं अंधेरे में एक जोड़ी शॉट्स की कोशिश की है:

  • एक खाली मेनू बढ़ा-चढ़ाकर
  • mToolbar.inflateMenu(0)
  • moolbar.setMenu(null, null)
  • toolbar.setMenu(null, null)

उत्तर

77

मैं पूरी तरह यकीन नहीं है अगर यह तुम क्या मतलब है न ही कोशिश की है लेकिन।

mToolbar.getMenu().clear(); 

मेनू को साफ़ करना चाहिए।

मैं अभी भी अपने सभी मेनू निर्माण के लिए onCreateOptionsMenu का उपयोग कर रहा हूं हालांकि

संबंधित मुद्दे