set an OnClickListener for each button in a ListView's row

by Pzikit Bloo » Fri, 18 Apr 2008 15:13:39 GMT

Sponsored Links
 Hi guys,

I'm trying to create a ListView, with a TextView and two ImageButton
per row. The problem comes when I try to add an OnClickListener to
each button. I did in this way:

-- row.xml --
 <LinearLayout ....... >
   <TextView ...........  />
        android:src="@android:drawable/arrow_down_panel_bezel" />
    <ImageButton ...... />

-- .java --
  ImageButton ib1 = (ImageButton) this.findViewById(;
  ib1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {

But I get a NullPointerException.
What's the right way to do that?

Pzikit Bloo

set an OnClickListener for each button in a ListView's row

by Megha Joshi » Fri, 18 Apr 2008 23:32:32 GMT


You cannot set the listeners for your ListView's items in the Activity's
onCreate(), you should set the OnClickListeners inside the getView() method
of your List's adapter.



Sponsored Links

set an OnClickListener for each button in a ListView's row

by xingye » Mon, 21 Apr 2008 04:03:10 GMT

 see the multi- 
selected list is seem to yours.


Other Threads

1. Is it possible to run ADB shell command from inside an Android app

I am trying to run an ADB shell command from inside an android app
using the JAVA's Runtime.getRunTime.exec API. I am getting an error
"ERROR/ProcessManager(1041): Error running adb: Permission denied".
Wanted to check if there is any permission that I need to request to
get it working or that running the adb shell command would not be
allowed from with in the Android app.

I am able to execute other linux commands like 'ls' from the android
app though.



2. How to run the adb command with the emulator?


I try to run the 'adb shell' command with the emulator.
But all I get is 'error: device not found'.  Can you please tell me
how to setup my emulator to work with the 'adb shell' command'?

$ adb shell am instrument
error: device not found

Thank you.


3. free android programming book

4. Wrong resultCode when sending email?

5. Android File System Build Error

6. Video resolution support

7. How to extract an image from a video