You should specify the onclick handler within the button parameters. In this case:
<Button android:id="@+id/BTN_BOOK" android:layout_width="75dip" android:layout_height="wrap_content" android:text="@string/book_now" android:textSize="10px" android:onClick="methodToCallWhenClicked" ></Button> You can then pass any sort of string value to any object within the method created in your java file. On Feb 6, 2:46 pm, AndrewD <[email protected]> wrote: > Hello, > > As a beginner with Android, I'm always running into some sort of > issues but for this one in particular I need some expert advice. > > I am using a list view to list some data read from an xml. All works > with the template I created, however, for each item I included a > button. What I need to do is to give each button a handler to which I > would like to somehow pass a string value (or an object, both of them > would be related to the list item the button represents). > > This is the adapter I use for the list > > SimpleAdapter mSchedule = new > SimpleAdapter(this,results,R.layout.show_results_item,new String[] > {"train","dep","dest"}, new int[] > {R.id.TRAIN_CELL,R.id.TRAIN_DEP,R.id.TRAIN_DEST}); > > My item template: > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout > xmlns:android="http://schemas.android.com/apk/res/android" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:paddingTop="10dip" > > > > <TextView > android:id="@+id/TRAIN_CELL" > android:layout_width="30dip" > android:layout_height="wrap_content" > android:textSize="12px" > ></TextView> > > <TextView > android:id="@+id/TRAIN_DEP" > android:layout_width="100dip" > android:layout_height="wrap_content" > android:textSize="12px" > ></TextView> > > <TextView > android:id="@+id/TRAIN_DEST" > android:layout_width="100dip" > android:layout_height="wrap_content" > android:textSize="12px" > ></TextView> > > <Button > android:id="@+id/BTN_BOOK" > android:layout_width="75dip" > android:layout_height="wrap_content" > android:text="@string/book_now" > android:textSize="10px" > ></Button> > </LinearLayout> > > Anyone could tell me where I could specify the onclick handler? > > Thanks! -- 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

