Friday, March 4, 2011

[android-developers] Re: ListView update problem.

Hi Boston,
Thanks for your time.

Yes, i modify the values of the vectors, but not the size of the
vector. And after modifying my values, I call
adapter.notifyDataSetChanged();

Initially, the size of the ListView is 6 and the size of all the
Vectors is 5.

in getView() i write as below

if(position == 0){
holder.textView1.setText("Label1");
holder.textView2.setText("Label2");
holder.textView3.setText("label3");
}else{
holder.textView1.setText(vector1(position-1));
holder.textView2.setText(vector2(position-1));
holder.textView3.setText(vector3(position-1));
}

int getCount(){
return vector1.size() + 1;
}
Is adapter.notifyDataSetChanged() enough to reflect the changes?? Or i
have to set listView.setAdapter(adapter) again...

When i remove the below condition in getView(...)
if(position == 0){// apply different color to the row }else{// some
other code..}

It works well...
Its a mystery... :)


On Mar 4, 4:47 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> Just before you call this.notifyDataSetChanged(), do you modify the arrays
> scripVector, closeVector and changeVector?
>
> BTW: I see a LOG message that examines the count of list-view childer
> (aView.getChildCount()). The number of children in the list-view (aView) is
> not the same as the number of items in your adapter (i.e. the range of
> values that the 'position' can take in getView). The getChildCount is never
> larger than the items in the list-view that are currently (partially)
> visible in the listview, while the number of items in your adapter can be
> much much larger.

--
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