java - Android: How to disable list items on list creation -


I'm a lot new to Android developers and I'm still working a lot.

We have shown a main menu while using the following code, but how to disable the selected items in the menu can not be detected. Can anyone help me with some sample code?

  Public category list provides test list expanses {@ override public zero to crate (bundled saved location) {super.onCreate (savedState); SetListAdapter (ArrayAdapter.createFromResource (this, R.array.mainMenu, android.R.layout.simple_list_item_1)); // Not sure how to disable list items} Safe void onListItemClick (ListView List, View View, Integer Status, Long ID) {// can disable the item when they are clicked on view.setEnabled (false) Are; }}  

and I have string in my string.xm file:

   

thanks

creation to disable list items in the list You have to sub-quote from ArrayAdapter . You must override the following methods: is enabled (status of the int) and areAllItemsEnabled () . In the past you depend on the basis of true or false , if the list item is enabled in the given position or if you createFromResource () You also need to apply that method, because since false ArrayAdapter.createFromResource () still instead of your own adapter ArrayAdapter instantiates .

Finally, the code will look something like this:

  Class Menu Adapter ArrayAdapter extension & lt; Charsequence & gt; {Public menu adapters (reference references, int text viewcid, foursevenense [] strings) {super (context, text, VISID, wire); } Public Static Menu Adapter making FirmorSource (Reference Reference, At TextarreidID, Int TextVirID) {Resource Resources = Reference.Geterisource (); Charasata [] wire = resources .getTextArray (TEXTERIID); Return the new menu adapter (context, sendVRIID, wire); } Public boolean is enabled all items () {return false; } Public Boolean enabled (status of int) {// return incorrect if condition == position you want to disable}}  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -