Hi Patrick,

Thanks for getting back.

I don't think I understand your solution completely. Maybe I am too
exhausted to think straight.

Here is what I am trying to do, I have a custom listview with an icon,
textview and button on each row. There are 6 items in the listview and
each row button would bring up a different activity. I want to define
button onClick event inside my getView method to listen to the button
clicks on each row and take necessary action. As you can see, I am
setting the row icons under getView based on position. I want to use
the position information to now listen to respective button clicks.
Clueless!

Would you be able to help?


class CustomAdapter extends ArrayAdapter
        {
                CustomAdapter()
                {
                        super(kis.this, R.layout.row_kis, items);
                }


                public View getView(int position, View
convertView,     ViewGroup
parent)
                {
                        LayoutInflater inflater=getLayoutInflater();
                        View row=inflater.inflate(R.layout.row_kis,
parent, false);
                        TextView label=(TextView)row.findViewById
(R.id.label);
                        label.setText(items[position]);
                        ImageView icon=(ImageView)row.findViewById
(R.id.icon);
                        Button row_button = (Button) findViewById
(R.id.btlst1);


                        if (items[position].compareTo("Abhi") == 0) {


                                  icon.setImageResource
(R.drawable.alan);   //set icon for row with name "Abhi"


                        }


                        ...... and so on for other rows


                   }
        }


Thanks,

Abhishek

On Dec 21, 4:31 pm, Patrick Plaatje <pplaa...@gmail.com> wrote:
> My Apologies,
>
> i didn;t see the complete message thread earlier (thanx Gmail!). I hope my
> post did help you though. If not, reply again and i'll see if i can help.
>
> Regards,
>
> Patrick
>
>
>
> ---------- Forwarded message ----------
> From: Patrick Plaatje <pplaa...@gmail.com>
> Date: 2009/12/21
> Subject: Re: [android-developers] Re: button Click event inside custom
>
> listview.... Help!
> To: android-developers@googlegroups.com
>
> Abhishek,
>
> it's kinda hard to resolve this without any code, but here's how i solved
> it:
>
> in the main activity, i defined the following:
>
> setOnItemClickListener(new OnItemClickListener() {
>                 public void onItemClick(AdapterView<?> arg0, View arg1, int
> arg2,
>                         long arg3) {
> Log.d(this.getClass().getSimpleName, arrayList.get((int) arg3).toString);
> }});
>
> so within the onItemClickListener, i make a reference to my ArrayList and
> show them in the log.
>
> Hopes it helps,
>
> Regards,
>
> Patrick
>
> 2009/12/21 Abhi <abhishek.r.sha...@gmail.com>
>
> That didn't help..... :(
>
> > Can someone guide me to the right tutorial/sample code?
>
> > Thanks,
>
> > Abhishek
>
> > On Dec 18, 11:03 pm, android09 <pranav.jaja...@gmail.com> wrote:
> > > Hi Abhishek,
>
> > > You can to through the below example for creatingcustomview. Follow
> > > the below link.
>
> > >http://www.anddev.org/basic_drag_and_drop-t3095.html
>
> > > I hope you will get the something from the above example.
>
> > > Best Luck.
> > > Thanks.
>
> > > On Dec 18, 7:47 am, Abhi <abhishek.r.sha...@gmail.com> wrote:
>
> > > > Hi guys,
>
> > > > I have my owncustomadapter to create acustomlistviewwith
> > > > checkbox, textview and button in each row. I want to implement onClick
> > > > on Button and take different action based on which row button is
> > > > pressed. How can I use onClickListener in this case? Define it inside
> > > > getView? If so how?
>
> > > > Thanks
>
> > > > Abhishek- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > 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+unsubscr...@googlegroups.com<android-developers%2bunsubs­cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Met vriendelijke groet,
>
> Patrick Plaatje
>
> NDC|VBK de uitgevers
> Sixmastraat 32, 8915 PA Leeuwarden
> Postbus 394, 8901 BD Leeuwarden
> T   (058) - 284 5044
> M  (06) - 158 966 34
>
> --
> Met vriendelijke groet,
>
> Patrick Plaatje
>
> NDC|VBK de uitgevers
> Sixmastraat 32, 8915 PA Leeuwarden
> Postbus 394, 8901 BD Leeuwarden
> T   (058) - 284 5044
> M  (06) - 158 966 34- Hide quoted text -
>
> - Show quoted text -

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to