Thursday, November 1, 2012

Re: [android-developers] single selection listveiw

Thanks for reply me but i did that by check box.



following code i have used for that

checkProfileItem is object of checkbox and it is declare in ViewHolder class.

   holder.checkProfileItem.setId(position);
        holder.checkProfileItem.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
           
                for (int i = 0; i < ProfileListBean.profileList.size(); i++) {
                    if (v.getId() == i) {
                   
                    //holder.checkProfileItem.setChecked(true);
                    checkArray[i] = true;
                        //Log.v("check", ""+position);
                    } else {
                    checkArray[i] = false;
                    }
                }
                notifyDataSetChanged();
             }
            
        });
       
        if(checkArray[position]){
            holder.checkProfileItem.setChecked(true);
        } else {
            holder.checkProfileItem.setChecked(false);
        }
        

Thank you 
Regards,
Rauf Qureshi


On Wed, Oct 31, 2012 at 12:04 PM, Narendra Singh Rathore <nsr.curious@gmail.com> wrote:


On Wed, Oct 31, 2012 at 10:51 AM, rauf qureshi <qureshirauf7@gmail.com> wrote:
hello friends,
 
I am developing listview with customerAdapter which extends baseAdapter,in each item of list there is two textview and one check box is there , so i want to select one check box at a time but i am unable to do that can any body give me solution for that

Hi Rauf,
I guess RadioButton is better way to do what you want, as you can use RadioGroup, as parent view to the radiobuttons if you want single selection.

As well as I guess using checkbox should be preferred in case of selecting multiple items.

You can ask if you have further queries.


Thanks and Regards,
NSR

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment