We are using list view in our app with one simple row layout.
But on click of list view we want to change the row layout of
tht particular item . is it possible to do ? wht is the best approach ?
Ho to add listeners to view inside the row layout?
To do something like that you are going to have to write a custom
adapter... When the listview item is clicked you then set the clicked
status on the adapter for the clicked item, call notifyDataSetChanged() and
let the getView() method handle the change...
On Thu, Aug 9, 2012 at 1:46 AM, Jovish P <android.f...@gmail.com> wrote:
> We are using list view in our app with one simple row layout.
> But on click of list view we want to change the row layout of
> tht particular item . is it possible to do ? wht is the best approach ?
> Ho to add listeners to view inside the row layout?
> --
> 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
There is no way that you do it with the adapters that already exist. You have to create your own. The adapter's getView method is responsible for creating and displaying every single row. Let's suppose that you need only two row layout to switch with. In that case the model used with the adapter could have an attribute to tell if it is using row type 1 or 2. In the onclick you change the model of the clicked item, you choose its row type and you notify that the data have changed with notifyDataSetChanged().
On Thursday, August 9, 2012 7:46:22 AM UTC, Jovish P wrote:
> We are using list view in our app with one simple row layout. > But on click of list view we want to change the row layout of > tht particular item . is it possible to do ? wht is the best approach ? > Ho to add listeners to view inside the row layout?
we are using a custom adapter only. in the adapter in getview method we
are setting a tag for the first time. "isSelected" as false
and on click we change the tag value as true and invalidating the listview
with invalidateviews. so we are making ui changes in the row layout based
on this tag value. But the problem we are facing now isif i click on first
item the change happens on some other row layout. some problem while
reusing the layout we guess. any one have any idea regarding this.
On Sat, Aug 11, 2012 at 6:09 PM, log4droid <adilour...@gmail.com> wrote:
> There is no way that you do it with the adapters that already exist. You
> have to create your own. The adapter's getView method is responsible for
> creating and displaying every single row. Let's suppose that you need only
> two row layout to switch with. In that case the model used with the adapter
> could have an attribute to tell if it is using row type 1 or 2. In the
> onclick you change the model of the clicked item, you choose its row type
> and you notify that the data have changed with notifyDataSetChanged().
> Tell us if it works for you.
> On Thursday, August 9, 2012 7:46:22 AM UTC, Jovish P wrote:
>> We are using list view in our app with one simple row layout.
>> But on click of list view we want to change the row layout of
>> tht particular item . is it possible to do ? wht is the best approach ?
>> Ho to add listeners to view inside the row layout?
>> --
> 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
> we are using a custom adapter only. in the adapter in getview method we
> are setting a tag for the first time. "isSelected" as false
> and on click we change the tag value as true and invalidating the
> listview with invalidateviews. so we are making ui changes in the row
> layout based on this tag value. But the problem we are facing now isif i
> click on first item the change happens on some other row layout. some
> problem while reusing the layout we guess. any one have any idea regarding
> this.
Don't do it this way... Do it the way I described in my first reply to your
question.
On Sun, Aug 12, 2012 at 8:03 AM, Jovish P <android.f...@gmail.com> wrote:
> we are using a custom adapter only. in the adapter in getview method we
> are setting a tag for the first time. "isSelected" as false
> and on click we change the tag value as true and invalidating the
> listview with invalidateviews. so we are making ui changes in the row
> layout based on this tag value. But the problem we are facing now isif i
> click on first item the change happens on some other row layout. some
> problem while reusing the layout we guess. any one have any idea regarding
> this.
Justin Anderson , how to set clicked status on the adapter for the clicked
item ? Can you explain a little bit more if you don't mind. It will be a
great help for us.
Thanks ,
Jovish
On Sun, Aug 12, 2012 at 8:41 PM, Justin Anderson <magouyaw...@gmail.com>wrote:
> we are using a custom adapter only. in the adapter in getview method we
>> are setting a tag for the first time. "isSelected" as false
>> and on click we change the tag value as true and invalidating the
>> listview with invalidateviews. so we are making ui changes in the row
>> layout based on this tag value. But the problem we are facing now isif i
>> click on first item the change happens on some other row layout. some
>> problem while reusing the layout we guess. any one have any idea regarding
>> this.
> Don't do it this way... Do it the way I described in my first reply to
> your question.
> On Sun, Aug 12, 2012 at 8:03 AM, Jovish P <android.f...@gmail.com> wrote:
>> we are using a custom adapter only. in the adapter in getview method we
>> are setting a tag for the first time. "isSelected" as false
>> and on click we change the tag value as true and invalidating the
>> listview with invalidateviews. so we are making ui changes in the row
>> layout based on this tag value. But the problem we are facing now isif i
>> click on first item the change happens on some other row layout. some
>> problem while reusing the layout we guess. any one have any idea regarding
>> this.
> --
> 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
On Monday, August 13, 2012 4:05:55 AM UTC-4, Jovish P wrote:
> Justin Anderson , how to set clicked status on the adapter for the > clicked item ? Can you explain a little bit more if you don't mind. It will > be a great help for us.
> Thanks , > Jovish
What he means is that you should add a boolean in your data model for list items and use that instead of setting a tag in the view. What you are doing is storing your data in your view which is wrong from an MVC point of view.
> What he means is that you should add a boolean in your data model for list
> items and use that instead of setting a tag in the view. What you are doing
> is storing your data in your view which is wrong from an MVC point of view.
On Mon, Aug 13, 2012 at 11:23 AM, Nadeem Hasan <nha...@nadmm.com> wrote:
> What he means is that you should add a boolean in your data model for list
> items and use that instead of setting a tag in the view. What you are doing
> is storing your data in your view which is wrong from an MVC point of view.