开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜