开发者

Making the cell of a listview clickable in listview in android

hi how to make the cell of a listview clickable in listview in android ? The list view is in Activit开发者_开发百科y and not in ListActivity


listView.setOnItemClickListener(new OnItemClickListener() 
    {
        @SuppressWarnings("static-access")

        public void onItemClick(AdapterView<?> arg0, View v, int position,long id)
        {
            // Your Code
            // Use Position
        }
    }


Try this

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ListView list = getListView();
        list.setBackgroundResource(R.drawable.background);

        ListAdapter adapter = createAdapter();
        setListAdapter(adapter);

        list.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View v, int position,
                    long id) {
                System.out.println("" + position);
                callGridView(position);
            }// end of onItemClick
        });// end of setOnItemClickListener
    }// end  of oncreate
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜