i am writing a code to show a multiple selection list (one having check boxes) and when the user checks an item i want to retrieve user's name and id from database table and display it in toast. Here's the code:
Activity code
public class Add_To_Circle extends Activity {
ListView lv;
ListAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_to_circle);
// Get listview
lv = (ListView)findViewById(R.id.list);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
... //all the other code,and then in another class in postexecute there is adapter:
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
//pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
adapter = new SimpleAdapter(
Add_To_Circle.this, productsList,
android.R.layout.simple_list_item_multiple_choice, new String[] { TAG_PID,
TAG_NAME},
new int[] { R.id.pid, R.id.name });
// updating listview
lv.setAdapter(adapter);
}
});
}
}
Code of XML file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
the output: a blank listview with only checkboxes as in the attched image. What am i doing wrong? i have followed same steps as in tutorials on web still no luck :((