ListView with OnItemClickListener android


Hey check this, works for me... hope it work for u too

If list item contains ImageButton

Problem: OnItemClickListener just doesn’t repond any at all!

Reason: No idea

Solution: in code, set ImageButton's focus to “false”

1: ImageButton button = (ImageButton) convertView.findViewById(;

2: button.setFocusable(false);


I am using a custom ListView with RatingBar and ImageButton. Here is my problem: When I click on my ListView, my OnItemClickListener is not working. Please can any one help me. Code:

ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener()
    public void onItemClick(AdapterView<?> arg0, View arg1,int position, long arg3)
        Toast.makeText(SuggestionActivity.this, "" + position, Toast.LENGTH_SHORT).show();

Thanks in advance!

How to make a onClick for a ListView item?

Your MainActivity should look like this.

    package com.example.uilistview;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends ListActivity {

    protected void onCreate(Bundle savedInstanceState) {
        setListAdapter(new ArrayAdapter<String>(this, R.layout.activity_main,

        ListView lv = getListView();
        lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
                public void onItemClick(AdapterView<?> arg0, View view, int arg2,
                        long arg3) {
        Intent intent = new Intent(MainActivity.this, SecondActivity.class);

    } );  }

Android: Disable checkboxes without graphical change?

Gosh, so easy... setClickable(false) or android:clickable="false". That's it.

Override onListItemClick in your ListActivity and start your second activity from there:

protected void onListItemClick(ListView l, View v, int position, long id) {
    Intent intent = new Intent(this, SecondActivity.class);

The problem is that your layouts contain either focusable or clickable items. If a view contains either focusable or clickable item the OnItemCLickListener won't be called.

Click here for more information.

Please post one of your layout xmls if that isn't the case.