Expecting some solution for implemeting listview with checkboxes ..... [duplicate]
Possible Duplicate:
Getting an issue while checking the dynamically generated checkbox through list view
I want to implement a listview with textview and checkbox per row of a list. I am doing that using LayoutInflator. By this I am getting whatever I want in a list. But whenever I scroll the list, functions from my listviewadapter class calls again and again and recycles the list every time.
Because of this my checkbox state is not maintaining and also if I checked first item of list it will also checks the second last item of a list itself. I tried to find out by debugging my code. I came to know that once my all items from arraylist got its view this getView() function picks some random position and replace the view on that position.
I am totally confused ........ has anybody implemented such kind of listview please tell me the solution.
Thanks.
The solution is here, Knickedi has nicely explained the working of ListView and also the problem why the checkbox is behaving in a weird manner.
use alert dialog box...
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(<title>);
builder.setMultiChoiceItems(<List_View_Item_Array>, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1, boolean arg2) {
}
});
AlertDialog alert = builder.create();
alert.show();
精彩评论