开发者

Can i get onClickListener for this list listed by CustomAdapter?

开发者 https://www.devze.com 2023-04-12 14:17 出处:网络
I have listed a list with custom adapter to display different images in each list item and su开发者_Go百科cceeded.

I have listed a list with custom adapter to display different images in each list item and su开发者_Go百科cceeded. Now i need to add a onitemclick listener for that list. Unable to access the id because the list id is - "@+id/android:list". Unable to identify this id.

Any ideas please share. You will get some more idea when you see this below link

Click here for the example i tried.


In the given example, the ListActivity is extended in CustomAdapterActivity.java

so its simple to get Click events of the list items by writing list item click listener

and to write onClickListener you need to do

like this in that class.

**

public class Test extends ListActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        ListView lv = getListView();
        lv.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

            }
        });
    }
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
    }

    }

**

And To Know More and Learn About LIST VIEW in Android you can view this : http://www.vogella.de/articles/AndroidListView/article.html#overview_listview

0

精彩评论

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

关注公众号