Kumar, Here is the excerpt of getView method in my code.
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 } } See if this helps. Thanks, Abhishek On Dec 18, 5:42 am, Kumar Bibek <coomar....@gmail.com> wrote: > What you are doing is right, > > holder.map.setOnClickListener(new OnClickListener(){ > public void onClick(View v){ > // Wirte your code > } > ); > > On Dec 18, 3:20 pm, Geoffrey Monté <mgeoff...@gmail.com> wrote: > > > > > I have the same request: > > this is my getView method : > > public static class ViewHolder > > { > > TextView libelle; > > TextView ville; > > Button map; > > Button itineraire; > > } > > > public View getView(int position, View convertView, ViewGroup > > parent) > > { > > // TODO Auto-generated method stub > > ViewHolder holder; > > > if(convertView==null){ > > convertView= > > myInflater.inflate(R.layout.store_list_item, null); > > holder= new ViewHolder(); > > > holder.libelle=(TextView)convertView.findViewById > > (R.id.store_libelle); > > > > > holder.ville=(TextView)convertView.findViewById(R.id.store_ville); > > convertView.setTag(holder); > > }else{ > > holder=(ViewHolder) convertView.getTag(); > > } > > > holder.ville.setText(store.get(position).Ville); > > holder.libelle.setText(store.get(position).libelle); > > //holder.map.setOnClickListener(this); > > return convertView; > > } > > > I want to set an onclick on the map button and on the itinerary > > button... > > those click launche a new activity. > > > On 18 déc, 06:48, Kumar Bibek <coomar....@gmail.com> wrote: > > > > If you can post an excerpt of your getView method. I can show you.... > > > > Thanks, > > > Kumar Bibek. > > > > On Dec 18, 10:02 am, Abhi <abhishek.r.sha...@gmail.com> wrote: > > > > > Hi Kumar, > > > > > Can you show me how to do that? I am not getting the right method to > > > > do this. > > > > > Thanks, > > > > > Abhishek > > > > > On Dec 17, 11:49 pm, Kumar Bibek <coomar....@gmail.com> wrote: > > > > > > Yes, you will have to define the listener inside the Custom adapter, > > > > > in the getView Method, on the button. > > > > > > Thanks, > > > > > Kumar Bibek > > > > > >http://tech-droid.blogspot.com > > > > > > On Dec 18, 7:47 am, Abhi <abhishek.r.sha...@gmail.com> wrote: > > > > > > > Hi guys, > > > > > > > I have my own custom adapter to create a custom listview with > > > > > > 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 For more options, visit this group at http://groups.google.com/group/android-developers?hl=en