How to make a ListActivity item with many Views in inside clickable
this probably is a popular question so sorry if I'm asking the obvious but I couldn't find an answer. Basically I've got a ListActivity which is being populated by LinearLayout which has many Views in it. I just want the bars to be clickable and selectable as at the moment they do not respond to clicks. Thanks.
implement OnClickListener as part of class definition and register the linearlayout (or any widget) to listener. snippet as follows
LinearLayout content;
content = (LinearLayout) findViewById(R.id.<layoutid>);
content.setOnClickListener(this);
...
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.<layoutid>:
//TODO your actions
break;
}
}
Fixed this. Since my class signature is this:
public class ResultsPage extends ListActivity {
I needed to implement this method to make it work:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// code
}
精彩评论