I figure it's easy enough to copy a text file or CSV file from my computer to the phone, but I need to the app to read in the text file and be able to randomize a list from clicking the button.
I have created a very simple app that takes a list of movie titles and randomizes that list into a listview when clicking the button.
Now I need to download a text or CSV file, that contains a larger list into the app.
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button getList;
ListView movieList;
ArrayList<String> moviePicks;
long seed = System.nanoTime();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getList = (Button) findViewById(R.id.btnGetList);
getList.setOnClickListener(this);
movieList = (ListView) findViewById(R.id.LV_Movies);
moviePicks = new ArrayList<String>();
moviePicks.add("Star Wars: A New Hope");
moviePicks.add("Star Wars: Revenge of the Jedi");
moviePicks.add("Die Hard");
moviePicks.add("The Pink Panther");
moviePicks.add("Hunt for Red October");
moviePicks.add("Swat");
moviePicks.add("Entrapment");
moviePicks.add("Back to the Future");
moviePicks.add("Jaws");
moviePicks.add("The Fast and the Furious");
moviePicks.add("Rounders");
moviePicks.add("Pearl Harbor");
moviePicks.add("Doom");
moviePicks.add("Hells Gate");
moviePicks.add("Avatar");
moviePicks.add("Coaster");
moviePicks.add("Brick Mansions");
}
@Override
public void onClick(View view) {
Collections.shuffle(moviePicks, new Random(seed));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, moviePicks);
movieList.setAdapter(arrayAdapter);
}
How can I have a text file read in as the list to be randomized?