如何将Bundle Array值发送到android中的另一个活动?
我有一个类(sun.java)。它生成包类型数组。我需要另一种行为中的String格式的Bundle类型数组。
帮帮我
提前致谢
Sun.java class`enter
self.menus[l].innerHTML = html;
self.container.appendChild(self.menus[l]);
self.onMenu.forEach(function(func){<--this is sometimes running before appendChild has loaded, causing an error. Would Chrome be caching this 'state'
func.call(self.menus[l],self);
});
self.pagination.current++;
self.enable();
seconActivity是
Intent intent=new Intent(PaymentPageActvity.this,CancelPaymentActivity.class);
Bundle b=new Bundle();
b.putBundle("inErrorMessage",inResponse);
Log.i("Error","onTransactionFailure :"+inErrorMessage);
Log.i("Error","onTransactionFailure :"+inResponse);
//intent.putExtras(inResponse);
//app.getLogger().error("Transaction Success :" + inResponse);
intent.putExtras(b);
startActivity(intent);
在logcat中我得到了这个值
Bundle b=CancelPaymentActivity.this.getIntent().getExtras();
Bundle array=b.getBundle("inErrorMessage");
Log.i("array",""+array);
答案 0 :(得分:0)
您将其放入用于启动活动的意图的额外内容中。查看Google Docs for Intent Class
答案 1 :(得分:0)
您可以通过包对象发送string[]
或ArrayList<String>
,如下所示
Bundle bundle=new Bundle();
bundle.putStringArray("STRING_ARRAY", yourStringArray);
bundle.putStringArrayList("STRING_ARRAY_LIST", stringArrayList);
Intent intent =new Intent(this, YourClass.class);
intent.putExtras(bundle);
希望这有帮助