Mark has been repeatedly saying "don't call getview"
Adding to it, your call to adapt.notifyDataSetChanged(); is what's going to
trigger a getView() call for each of the items visible in your list. So some
internal code in  listview widget is what's going to call getview, not the
user(you). However deciding what view to return as per the arguments
(especially position) passed to getview is what user is supposed to take
care of. Google up some listview-baseadapter examples to figure out what's
the data model. Generally its a list or array of data objects whose size you
return in adapt.getcount, whose data fields you use while constructing or
updating a view inside getview, whose primary key you return i n
adapt.getitemid().
So replace the getview call in your onitemclick or any other UI listener
with
update_affected_dataobjects_of_your _data_model_thats_inside_the_adapter();
then call adapt.notifyDataSetChanged();

If you look carefully at the BaseAdapter API, getview, getcount etc. are
abstract methods. You implement them and decide what you are going to return
to the system, but you dont call them.

On Fri, Dec 3, 2010 at 1:35 AM, kiros88 <[email protected]> wrote:

> Okay so i guess this kinda makes sense I'm not really sure how am i
> suppose to change my data model. I did
> ((TextView)adapt.getView(0, null, parent)).setText("hello");
> adapt.notifyDataSetChanged();
>
> but nothing changed ?
>
>
> On Dec 2, 11:28 am, Mark Murphy <[email protected]> wrote:
> > Of course. Again, ordinarily, you do not call getView().
> >
> > You are going about your problem in the wrong way. You are attempting
> > to change your UI directly by grabbing some row out of a ListView and
> > changing it. That's not going to be reliable at all, since that row
> > might not exist. Rather, you need to change your data model (whatever
> > you have an Adapter on), then update the ListView from the revised
> > model. The way you would update the ListView varies by your type of
> > Adapter, and it may be automatic.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Dec 2, 2010 at 2:18 PM, kiros88 <[email protected]> wrote:
> > > Okay wait so i get the concept tthat u do a getView from an
> > > ArrayAdapter but what i tried this before during the
> >
> > > i called the adapter i used
> > > ArrayAdapter adapt = new
> > > ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 ,
> > > songs);
> >
> > > then after its already created i do
> >
> > > public void onItemClick(AdapterView<?> parent, View view,
> > >                        int position, long id) {
> >
> > > ((TextView)adapt.getView(position+1,null,parent)).setText("hello");
> >
> > > And this doesnt work it crashes the app
> >
> > > On Dec 2, 11:06 am, kiros88 <[email protected]> wrote:
> > >> Okay like where do u gets getView I dont see that function in the
> > >> Listview class or the adapterView class so im not really sure where im
> > >> suppose to be able to call getView.
> >
> > >> On Dec 1, 7:54 pm, Prakash Iyer <[email protected]> wrote:
> >
> > >> > My 2c - you are over-complicating this.The getView is ONLY to give
> back the
> > >> > view for the item that is requested. If you want this item to be
> colored X
> > >> > then do it here. If you want another item to be colored Y then do it
> when
> > >> > getView is called for that item. The state maintenance, i.e. what is
> X or Y
> > >> > is done independent of the code within getView which needs to just
> return
> > >> > the View...
> >
> > >> > As for the specific text, if you are returning a TextView t, then
> t.setText
> > >> > would work.
> >
> > >> > On Wed, Dec 1, 2010 at 9:14 PM, kiros88 <[email protected]> wrote:
> > >> > > Okay i dont want to get to many ppl confused so im going to try to
> ask
> > >> > > this very simply. When android goes to this function when a user
> > >> > > clicks on a item on your listview. basically u get a parent who im
> > >> > > assuming is the array of textview that was set up during the
> > >> > > setAdapter phase and view which the the corresponding View to
> which
> > >> > > the user touched.   My main and only questions is i know i can
> adjust
> > >> > > the view of View by saying stuff like
> >
> > >> > > (TextView)view = setText("hello")
> >
> > >> > > during the same time i want to beable to change another TextView
> in
> > >> > > the AdapterView like the View after the "View view" so i guess
> view
> > >> > > +1   i want to also be able to change that view into another word.
> >
> > >> > > Please dont ask me y im doing this just that im doing it for a
> reason
> > >> > > I just really need help and i hope this explains that During the
> > >> > > onItemClick listener function basically I want to adjust 2
> different
> > >> > > Views in the arrays of Views but i have no idea how to access the
> any
> > >> > > other view then the given "View view" thats the argument they give
> you
> >
> > >> > > --
> > >> > > 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]<android-developers%[email protected]><android-developers%2Bunsubs
> [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]<android-developers%[email protected]>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|
> http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
> >
> > _Android Programming Tutorials_ Version 3.0.1 Available!
>
> --
> 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]<android-developers%[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

Reply via email to