In ListView make only Buttons to be clickable
<p>I have implemented a list view.</p>

<p>Each item in my list view has two elements - a TextView and a Button.</p>

<p>Now I have Implemented ArrayList Adapter in order to make my listview clickable.</p>

<p>Currently what is happening that whenever I click any element in my listview my OnItemClickListener is called.</p>

<p>Now what I want to do is that I want to make only my button clickabe and not the entire element.</p>

<p>Here is the code that I have  implemented.</p>

<pre><code>public class SurveyListActivity extends ListActivity {


static private ArrayList&lt;Survey&gt; EU=new ArrayList&lt;Survey&gt;();

static {

        EU.add(new Survey(R.string.Survey1, R.drawable.completed,R.string.Survey1));
        EU.add(new Survey(R.string.Survey2, R.drawable.completed,R.string.Survey2));
        EU.add(new Survey(R.string.Survey3, R.drawable.inprogress,R.string.Survey3));
        EU.add(new Survey(R.string.Survey4, R.drawable.inprogress,R.string.Survey4));
        EU.add(new Survey(R.string.Survey5,R.drawable.inprogress,R.string.Survey5));
        EU.add(new Survey(R.string.Survey6, R.drawable.start,R.string.Survey6));

}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setListAdapter(new SurveyAdapter());
}

@Override
protected void onListItemClick(ListView l, View v,int position, long id) 
{

    Toast.makeText(SurveyListActivity.this, "You Selected :- " + EU.get(position).name, Toast.LENGTH_LONG).show();

}

static class Survey 
{
    int name;
    int status;
    int result;

    Survey(int name, int status, int result) 
    {
        this.name=name;
        this.status=status;
        this.result=result;
    }
}

class SurveyAdapter extends ArrayAdapter&lt;Survey&gt; 
{
    SurveyAdapter() 
    {

        super(SurveyListActivity.this, R.layout.row, R.id.name, EU);
    }


    @Override
    public View getView(int position, View convertView,
    ViewGroup parent) 
    {
        SurveyWrapper wrapper=null;

        if (convertView==null) 
        {
            convertView=getLayoutInflater().inflate(R.layout.row, null);
            wrapper=new SurveyWrapper(convertView);
            convertView.setTag(wrapper);
        }
        else 
        {
            wrapper=(SurveyWrapper)convertView.getTag();
        }

        wrapper.populateFrom(getItem(position),position);
        return(convertView);
    }
}

class SurveyWrapper 
{
    private TextView name=null;
    private ImageView status=null;
    private View row=null;

    SurveyWrapper(View row) 
    {
        this.row=row;
    }

    TextView getName() 
    {
        if (name==null) 
        {
            name=(TextView)row.findViewById(R.id.name);
        }
        return(name);
    }

    ImageView getstatus() 
    {
        if (status==null) 
        {
            status=(ImageView)row.findViewById(R.id.flag);
        }
        return(status);
    }

    void populateFrom(Survey survey, int i) 
    {
        if((i%2)!=0)
        {

            row.setBackgroundColor(Color.LTGRAY);
            getName().setBackgroundColor(Color.LTGRAY);
        }
        getName().setText(survey.name);
        getstatus().setImageResource(survey.status);

    }
}

}
</code></pre>
