开发者

How to make a ListActivity item with many Views in inside clickable

开发者 https://www.devze.com 2023-02-02 18:16 出处:网络
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

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

精彩评论

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