开发者

create a list view in android and if click it goes to next activity [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to go to a particular activity on list item click?

after clicking a listitem how i can go the next activity ? I have a listview where three items are there when i click one item 开发者_开发知识库it call next activity


Call this on click:

Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);


Try this, for each item in listview set on click listner

listitem01.setOnClickListener(new OnClickListener() {

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

            Intent myIntent = new Intent(v.getContext(),
                    NextActivity.class);
            startActivityForResult(myIntent, 0);

             finish();

        }
    });


try this code

setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
switch(position)
{
case 0:
startActivity(new Intent(this, SecondActivity.class)); break;
case 1:
startActivity(new Intent(this, SecondActivity.class)); break;
case 2:
startActivity(new Intent(this, SecondActivity.class)); break;
}

} 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜