好的,现在我想不出这个,那应该很简单。我已经阅读了很多 StackOverflow 问题,但仍然一无所获。我只想在用户点击列表后开始一个新的活动。太简单了!
public class Lista2Activity extends ListActivity {
TextView selection;
String[] items={"lorem", "ipsum", "dolor", "sit", "amet",
"consectetuer", "adipiscing", "elit", "morbi", "vel",
"ligula", "vitae", "arcu", "aliquet", "mollis",
"etiam", "vel", "erat", "placerat", "ante",
"porttitor", "sodales", "pellentesque", "augue", "purus"};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
selection=(TextView)findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View v, int position,long id) {
super.onListItemClick(parent, v, position, id);
selection.setText(items[position]);
Intent hash=new Intent(getApplicationContext(),another.class);
startActivity(hash);
}
}
它在这方面失败了Intent
。