可能重复: How从一个活动将值传递给另一个机器人?
我有一个标题(从ApiDemos list6例子)名单,他们的尸体(内容)的活动。我有一个活动,在这里我想补充的说明。当我点击添加按钮,我希望我的笔记的标题出现在列表中。同样的,身体。问题是,在名单的活动有两个String []数组与predefined硬codeD标题和机构。我应该怎么做才能够与内容,而无需这些硬件codeD值添加自己的新游戏? 我知道我必须使用意图与startActivityForResult,但是这可能是我所知道的......
I have an activity with a list of titles and their bodies(content) (list6 example from ApiDemos). And I have an activity, where I add a note. When I click on "Add" button, I want the title of my note to appear on the list. Same with body. The problem is, that in List activity there are two String[] arrays with predefined hard-coded titles and bodies. What should I do to be able to add my own new titles with a content instead of having these hard-coded values? I know I must use intents with startActivityForResult, but that's probably all I know...
您有两个选项:
此方式,可以使用它的情况相同,从与添加按钮的活动,并修改列表视图为:
This way you can use the same instances of it from the activity with add button and modify the listview as:
FirstActivity.listTitlesArrayList.add(listTitleString);
FirstActivity.listDescriptionArraylist.add(listDescriptionString);//this is probably your note
FirstActivity.listView.invalidateViews();
而要去ListActivity通数据通过。
while going to the ListActivity pass data by..
intent.putExtra("Title", listTitleString);
intent.putExtra("Content", listDescriptionString);
startActivity(intent);
和恢复它的第二个活动使用的:
and to recover it in second activity use:
title= getIntent().getExtras().getString("Title");
...等..
...and so on..