How can I start an activity when the user clicks on a ListItem?
Here is my code. I'd like to pass a boo开发者_开发技巧lean to the activity i want to start.
private void setupUI() {
setContentView(R.layout.more_tab_activity);
listView = (ListView) findViewById(R.id.streamListView);
listView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , streams));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
//start the streamactivity
}
});
}
Have you looked at any tutorials?
Intent i = new Intent(MyActivity.this, StreamActivity.class);
i.putExtra("id", true);
startActivity(i);
精彩评论