Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass ArrayList from Activity to ListFragment?

I am trying to implement a fragment layout. I have an activity that servers as a SplashScreen & fetches some data from the web and creates an ArrayList of my custom objects.

Normally If I were using a ListView I would just do the following.

private ArrayList<Articles> articles;

private void isComplete() {
         Intent intent = new Intent(SplashScreen.this, ListActivity.class);
         intent.putExtra("data", articles);
         startActivity(intent);
         finish();
    }

How can I do pass the same data to a Fragment? Your help I much appreciated.

like image 671
Byron Avatar asked Dec 05 '25 02:12

Byron


1 Answers

Its simple take Global class And declare public static ArrayList<Articles> articles = new ArrayList<Articles>; In main Activity Global.articles = articles ; Now u can use any where in Project.

like image 188
Parag Chauhan Avatar answered Dec 06 '25 15:12

Parag Chauhan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!