取一个的ListItem内的信息,并将其发送到下一个活动发送到、并将其、信息、ListItem

2023-09-04 05:12:13 作者:一路荒凉如歌

我是比较新的Eclipse的&放大器; ADT插件的世界,所以任何答案,能否请您解释一下它在做什么?这将是非常有益的。

I am relatively new to the Eclipse & ADT plugin world, so any answers can you please explain what it's doing? It would be very helpful.

基本上,我有一个列表中的一个活动,将通过从数据库API HTTP请求来填充,这个我还在工作。不过,我想知道,是我能够把字符串中的列表项,并把那个给一个TextView在接下来的活动?

Basically, I have a list in one activity that will be populated by a HTTP request from a database API, this I am still working on. However, what I wish to know, is am I able to take the string in the ListItem and give that to a TextView in the next activity?

因此​​,例如,我点击记录1,它需要记录1,并将其放入一个变量中,然后向用户发送到下一个屏幕,并插入变量转换成一个TextView。这可能吗?

So for example, I tap 'Record 1' and it takes 'Record 1' and puts it inside a variable, then sends the user to the next screen, and inserts the variable into a TextView. Is this possible?

感谢你。

推荐答案

获取你想要的东西从适配器,然后将其写入要启动的新活动的意图:

Get what you want from the adapter, then put that into the Intent that starts the new activity:

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String string = parent.getAdapter().getItem(position);
            Intent intent = new Intent(this, nextActivity.class);
            intent.putExtra("text", string);
            startActivity(intent);
        }
    });

在新的活动,你再拿到开始新的活动的意图和得到字符串你把它:

In the new Activity you then get the Intent that started the new Activity and get the String you put into it:

String data = getIntent().getStringExtra("text");