开发者

How can I start an activity when the user clicks on a ListItem?

开发者 https://www.devze.com 2023-01-26 14:45 出处:网络
Here is my code. I\'d like to pass a boo开发者_开发技巧lean to the activity i want to start. private void setupUI() {

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

精彩评论

暂无评论...
验证码 换一张
取 消