[Solved] Add the values on ArrayList in Android [closed]


After getting value from intent:

ArrayList<String> arrayList = new ArrayList<String>();

valueaddlist = (Button) findViewById(R.id.valueaddlist);
        valueaddlist.setOnClickListener(new OnClickListener() {
           public void onClick(View v){
arrayList.add(product_id);
arrayList.add(product_title);
arrayList.add(product_image);
arrayList.add(product_price);
arrayList.add(product_desc);

   } 

valuedisplaylist = (Button) findViewById(R.id.valuedisplaylist);
        valuedisplaylist.setOnClickListener(new OnClickListener() {
           public void onClick(View v){
    Intent intent = new Intent(this,AddedListProducts.class);
    intent.putStringArrayListExtra("arrayList", (ArrayList<String>) arrayList);
    startActivity(intent);
   } 

May be this will help you.

In your second activity get the arraylist like :

 ArrayList<String> ar1=getIntent().getExtras().getStringArrayList("arrayList"); ArrayAdapter<String> arrayAdapter =      
         new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, ar1);
         lv.setAdapter(arrayAdapter);

Then have a look at this question to display arraylist: Populating a ListView using an ArrayList?

3

solved Add the values on ArrayList in Android [closed]