当前位置: 代码迷 >> Android >> Intent的putParcelableArrayListExtra方法可以设置ArrayList<HashMap<String, Object>>值吗?该如何解决
  详细解决方案

Intent的putParcelableArrayListExtra方法可以设置ArrayList<HashMap<String, Object>>值吗?该如何解决

热度:96   发布时间:2016-05-01 21:26:28.0
Intent的putParcelableArrayListExtra方法可以设置ArrayList<HashMap<String, Object>>值吗?
我想在intent中加上ArrayList<HashMap<String, Object>>类型的值通过broadc传递到activity中。
如下所示,但是提示错误,
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
intent1.putParcelableArrayListExtra("listItem", listItem);

错误信息:
The method putParcelableArrayListExtra(String, ArrayList<? extends Parcelable>) in the type Intent is not applicable for the arguments (String, ArrayList<HashMap<String,Object>>)

那么,putParcelableArrayListExtra具体是怎么用的呢?

通过实现Parcelable接口,能返回ArrayList<HashMap<String, Object>>对象吗?

------解决方案--------------------
Java code
private static final String EXTRA_DIRECTORY = "com.blackmoonit.intent.extra.DIRECTORY";void createPlaylist(ArrayList<Uri> aFileList) {    String theDefaultFolderPath = "/sdcard/playlists";     Intent theIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);    theIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,aFileList);    theIntent.setType("audio/*");    theIntent.putExtra(EXTRA_DIRECTORY,theDefaultFolderPath); //optional    try {        startActivity(theIntent);    } catch (Exception e) {        e.printStackTrace();    }}
  相关解决方案