Click here to Skip to main content
15,884,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Hi,
    I developed an application with listview checkbox and adapter. I need to get value of the checkedlistview item.How to do?


    String[] edc_name_list=new String{"Name","ID"};

    HashMap<String, String> hm;
    EditText inputSearch;

    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, edc_name_list);
    final ListView listView = (ListView) findViewById(R.id.lst_delete_items);
    listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
              {
                 @Override
                    public void onItemClick(AdapterView<?> parent, View view,
                            int position, long id)
                 {
            //Toast.makeText(getApplicationContext(), ""+listView.getSelectedItem().toString(), 1000).show();
                 }
             });



Please help!!!!!
Posted
Comments
User1454 10-Dec-14 6:52am    
SparseBooleanArray checked = listView.getCheckedItemPositions();
for (int i = 0; i < checked.size(); i++) {
if(checked.valueAt(i) == true) {
String tag = String.valueOf(listView.getItemAtPosition(checked.keyAt(i)));
Toast.makeText(getApplicationContext(), ""+tag, 5000).show();
Log.i("xxxx", i + " " + tag);
}

Solved :D:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900