checkboxes with list view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

checkboxes with list view

Postby gsk » Tue Nov 11, 2008 6:24 am

Hi ...
Iam developing an application , in which I used check boxes with a list view in a ListActivity.

In that listview , user has to check the items and he can do delete or update the items .
But when i check on that items i couldn't able to get the item id,which i was checked .

below code i was written ...

public class MyList extends ListActivity {



public static final String TAG="listofitems";

private String[] mStrings = {"Bleu de Septmoncel",
"Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore"};

List<String> list=Arrays.asList(mStrings);




@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.todolist);



setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,list));
// ListView lv= getListView().setTextFilterEnabled(true);

// Inform the list we provide context menus for items
getListView().setOnCreateContextMenuListener(this);

final ListView listView = getListView();

listView.setFocusable(false);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);


}


Please help me ..how to delete or edit items which i was checked in the list.
gsk
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Nov 05, 2008 11:12 am

Top

Postby MrSnowflake » Tue Nov 11, 2008 11:14 am

Create you own ListAdapter for the listview
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby gsk » Wed Nov 12, 2008 7:16 am

hi...
I created the list adapter ..
but iam not getting the items which i checked in the view.
gsk
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Nov 05, 2008 11:12 am

Postby desuvinodkumar » Tue Aug 11, 2009 7:50 am

Hi

Change ur adapter like this ....

ListAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_multiple_choice, // Use a template
// that displays a
// text view
c, // Give the cursor to the list adatper
new String[] {People.NAME}, // Map the NAME column in the
// people database to...
new int[] {android.R.id.text1});
Vinod...
User avatar
desuvinodkumar
Senior Developer
Senior Developer
 
Posts: 102
Joined: Mon Mar 23, 2009 6:51 am
Location: India

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests