2016-04-25 6 views
-1

どのように送信Arraylist別の活動に送信する??putExtraどのように新しいアクティビティArraylistに送信<STRING []>

@Override 
protected void onPostExecute(ArrayList<String[]> s) { 
    Intent newActivity = new Intent(main,ListadoUltimosRegistros.class); 
    newActivity.putExtra("LR",(ArrayList<String[]>)s); 
    newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    main.startActivity(newActivity); 
} 
+0

コメントが正しい、最も簡単な解決策は 'Serializable'としてそれを通じ送信することです。 – EpicPandaForce

+0

彼らの助けをありがとう! – xnikoja

答えて

3
you can use data serializable class and use in put extra statements 
Intent i = new Intent(getApplicationContext(), DataList.class); 
      i.putExtra("password", (Serializable) contactList); 
      startActivity(i); 
//and fetch the data as a 
if(getIntent().getSerializableExtra("password")!=null) 
{ 
      con=(ArrayList<Contact>)getIntent().getSerializableExtra("password"); 
      email_mobile = contactList.get(0)._emnumber; 
      pass__word = contactList.get(0)._password; 
} 
+0

コードに関連する説明を追加してください! – Sandeep

-1

これを試してください。

i.putStringArrayListExtra("list", your list); 

を取得するために:

iはインテントオブジェクトである
getIntent().getStringArrayListExtra(list) 

を送信するために

+0

私はこれを試してみましたが、新しいActivYで2次元配列を読み取ることはできません – xnikoja

+0

passBundleのmBundle = new Bundle(); List ' – EpicPandaForce

+0

ではなく、リスト'です。 mBundle.putSerializable( "2D配列"、arrayToSend); i.putExtras(mBundle); String [] [] arrayReceived = null;を取得するために使用します。 Object [] objectArray =(Object [])getIntent()。getExtras()。getSerializable( "2 D配列"); –

0

あなたのように、カスタム・オブジェクトを送信することができます

intent.putExtra("MyClass", obj); 

// To retrieve object in second Activity 
getIntent().getSerializableExtra("MyClass"); 
0

はこれを試してみてください。

onPostExecute for Sending。最終用途これを受けて

Intent newActivity = new Intent(main,ListadoUltimosRegistros.class); 
ArrayList<String> myList = new ArrayList<String>(); 
newActivity.putExtra("mylist", myList); 
newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
newActivity.startActivity(newActivity); 

ArrayList<String> myList = (ArrayList<String>) getIntent().getSerializableExtra("mylist"); 
+0

あなたのために働いていますか? –

関連する問題