create a list view in android and if click it goes to next activity [duplicate]
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;
}
}
精彩评论