0

I am having a Listview and two buttons in my Activity,

when ADD button clicked it will call some other activity for result, that activity return a intent with data, each time diff data in the intent received, and the title only added to the listview,

when SAVE button clicked, all the intent data would be saved in database,

So I need to create intent array ie

Inten[] intArray = new Intent[100];

and I need to copy the returned Intent each time onActivityResult(Intent data) to the Intent array as

intArray[i] = data;

How can I achieve this, If I can do this I can solve a big problem in my Project....

Following is the code I tried.... Intent[] intentArray = new Intent[100]; declared as this class variable

@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
    super.onActivityResult(reqCode, resultCode, data);
    if(resultCode == Activity.RESULT_OK)
    {
        switch(reqCode)
        {
            case 1:
                trigName = data.getStringExtra("TriggerName");
                subName = data.getStringExtra("SubName");

                intentArray[i] = data; i++;

                temp = new HashMap<String, String>();
                temp.put("Name", trigName);
                temp.put("Sub", subName);
                list.add(temp);
                adapter.notifyDataSetChanged();
                break;
        }
    }
} 
4

1 回答 1

0

猜测你没有说明你所提供的代码有什么问题......但是

删除对super.onActivityResult(reqCode, resultCode, data);

或者如果你需要调用它;处理完所需信息后,在最后调用它。

于 2012-06-22T22:56:01.713 回答