开发者

set onClick or onItemSelected for item in list view

开发者 https://www.devze.com 2023-03-20 11:50 出处:网络
I have a requirement that, in my list view I am having an image icon, a text view and a button. when I click on any one of these it should move me to next screen. I tried implementing these methods,

I have a requirement that, in my list view I am having an image icon, a text view and a button.

when I click on any one of these it should move me to next screen. I tried implementing these methods, but no success.

Can anybody help me?

Note:My class does not extends ListActivity rather only Activity.

Here is my code....

ListView listView = (ListView)findViewById(R.id.listView1);
listView.set开发者_C百科OnItemSelectedListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                Intent in2 = new Intent(City.this, TourDescription.class);
                startActivity(in2);

            }
            @Override
            public void onNothingSelected(AdapterView<?> arg0) {

            }

        });


You need to set OnItemClickListener, not OnItemSelectedListener

0

精彩评论

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