mytechead

Android & Wordpress Help center

Disable elements of ListView

In order to disable few elements of a list view, you need to implement your own ArrayAdapter by extending the ArrayAdapter class.

In this Custom ArrayAdapter class one can override areAllItemsEnabled() method to return false.Also, override the method isEnabled()  and return false for the items that you don’t wish to enable; for others return true.

Code :

@Override

public boolean areAllItemsEnabled() {

    return false; } 

@Override
public boolean isEnabled(int position){

if(!areAllItemsEnabled()){
  if(<your condition here>){
   return false; // disable the item
 }
}
 return true;  // enable the item
}


					
Advertisements

Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: