Hi Abhishek,

I have placed the converView = null; as my first line in getView() method.

Now, the problem, that i mentioned earlier is not there (multiple checkboxes
get selected when i select one checkbox in view).

But, when i scroll the view up and down, i lose my selected checkbox (it
get's unchecked).

any thoughts?


On Tue, Jul 26, 2011 at 10:03 PM, Simon Platten <
[email protected]> wrote:

>  ok, this isn't my code but its a good starting point:
>
>     public View getView(int position, View convertView, ViewGroup parent) {
>         View vi=convertView;
>         ViewHolder holder;
>         if(convertView==null){
>             vi = inflater.inflate(R.layout.item, null);
>             holder=new ViewHolder();
>             holder.text=(TextView)vi.findViewById(R.id.text);;
>             holder.image=(ImageView)vi.findViewById(R.id.image);
>             vi.setTag(holder);
>         }
>         else
>             holder=(ViewHolder)vi.getTag();
>
>         holder.text.setText("item "+position);
>         holder.image.setTag(data[position]);
>         imageLoader.DisplayImage(data[position], activity, holder.image);
>         return vi;
>     }
>
> This is what is happening, the method is called everytime a new item comes
> into view.  For new items 'convertView' will be null, you then assign a
> layout to the view and set-up any controls, the vi.SetTag, passes data to
> the view that you can use to work out what the item actually is.  In the
> example above it uses a background class 'imageLoader' to load the images in
> the background.
>
> Hope this helps.
>
> Regards,
> Simon
>
>
> On 26/07/2011 2:57 PM, Viral Brahmbhatt wrote:
>
> ok.. np.. thanks for your response.
>
>  plz note my skype id: viralbrahmbhatt.
>
>
>  if you can add me to your list, we can directly chat on this.
>
>  On Tue, Jul 26, 2011 at 7:20 PM, Simon Platten <
> [email protected]> wrote:
>
>> I'm at work atm, when I get home I will take a look, its 14:49 here (GMT)
>> shoudl be home at 17:30 ish.
>>
>>
>>
>> On Tue, Jul 26, 2011 at 2:23 PM, Viral Brahmbhatt <
>> [email protected]> wrote:
>>
>>> Hi Simon,
>>>
>>>  Find below my getView() method call.... let me know, what do i need to
>>> do?
>>>
>>>
>>>  -----------------------
>>>
>>>  public View getView(final int position, View converView, ViewGroup
>>> parent) {
>>>
>>>  ViewHolder holder;
>>>  try {
>>>  // TODO Auto-generated method stub
>>>
>>>  ImageView imageView = null;
>>>  TextView textView = null;
>>>  CheckBox chkbox = null;
>>>
>>>  if (converView == null) {
>>>  converView = mInflater.inflate(R.layout.custome_listview,null);
>>>
>>>  holder = new ViewHolder();
>>>  holder.text = (TextView) converView.findViewById(R.id.text);
>>>  holder.icon = (ImageView) converView.findViewById(R.id.imgview);
>>>  holder.chk = (CheckBox) converView.findViewById(R.id.chkbox);
>>>  converView.setTag(holder);
>>>  } else {
>>>  holder = (ViewHolder) converView.getTag();
>>>  }
>>>
>>>   holder.text.setText("TEST TEXT");
>>>  holder.icon.setImageDrawable(IMAGE FROM RESOURCE);
>>>  holder.chk.setId(1);
>>>
>>>  } catch (Exception ex) {
>>>  ex.printStackTrace();
>>>  }
>>>  return converView;
>>> }
>>>
>>>  ----------------------------------
>>>
>>> On Tue, Jul 26, 2011 at 6:34 PM, Simon Platten <
>>> [email protected]> wrote:
>>>
>>>> I am doing something very similar its because the views in the listview
>>>> are re-used as you scroll them out of view they are re-cycled for the new
>>>> views coming into view.
>>>>
>>>> You need to manage the change over in the getView method.
>>>>
>>>>
>>>>  On Tue, Jul 26, 2011 at 1:33 PM, Viral Brahmbhatt <
>>>> [email protected]> wrote:
>>>>
>>>>>  Hi there,
>>>>>
>>>>>  I am trying to implement a listview with image, text and checkbox
>>>>> within it, using baseadapter.
>>>>>
>>>>>
>>>>>  the problem is, let's say i have 20 items in list, so when i select
>>>>> the first item checkbox, and scroll down the list, i can see the item #9 
>>>>> and
>>>>> #17 also get checked automatically.
>>>>>
>>>>>  can anyone pls help me to understand what is it doing?
>>>>>
>>>>> --
>>>>> *Regards,
>>>>> Viral*
>>>>>   --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Android Developers" group.
>>>>> To post to this group, send email to
>>>>> [email protected]
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/android-developers?hl=en
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Sy
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Android Developers" group.
>>>> To post to this group, send email to
>>>> [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/android-developers?hl=en
>>>
>>>
>>>
>>>
>>> --
>>> *Regards,
>>> Viral*
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>
>>
>>
>>
>> --
>> Regards,
>> Sy
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>
>
> --
> *Regards,
> Viral*
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
*Regards,
Viral*

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

Reply via email to