How to transfer List<String>list= new ArrayList<>() to another one? Well or in ViewPager?

  • Any object (in other words, everything that is not a simple type of ala int can be) can be transferred via the interface parcelable - Silento

1 answer 1

You need to put your list of pages in the Intent, which you run the second activation using the Intent#putStringArrayListExtra(String key, ArrayList<String> list) . Then, in the second activation, you need to remove this list from the Internet using the key.

In the first activity:

 ArrayList<String> ar = new ArrayList<String>(); ar.add("Apple"); ar.add("Banana"); Intent i = new Intent(this, SecondActivityClassName.class); i.putStringArrayListExtra("list", ar); startActivity(i); 

In the second:

 ArrayList<String> ar1 = getIntent().getExtras().getStringArrayList("list"); 
  • So I have a List <String> and swears on imgUrls in intent.putStringArrayListExtra ("image", imgUrls); - sviter-pro 4:08 pm
  • @ sviter-pro, your message is not informative - without specifying the type of error and the example of the problem code in the question you cannot help - YuriySPb