如何在用户单击ListItem时启动活动?

时间:2010-11-19 23:08:33

标签: java android listview android-intent listviewitem

这是我的代码。我想将布尔值传递给我想要开始的活动。

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
            }
        });
    }

1 个答案:

答案 0 :(得分:2)

你看过任何教程吗?

Intent i = new Intent(MyActivity.this, StreamActivity.class);
i.putExtra("id", true);
startActivity(i);