How can I start an activity when the user clicks on a ListItem?
-
26-09-2019 - |
Question
Here is my code. I'd like to pass a boolean 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
}
});
}
Solution
Have you looked at any tutorials?
Intent i = new Intent(MyActivity.this, StreamActivity.class);
i.putExtra("id", true);
startActivity(i);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow