How to convert ArrayList to HashSet for eliminating duplicates

 

List<String> al = new ArrayList<>();
// add elements to al, including duplicates
Set<String> hs = new HashSet<>();
hs.addAll(al);
al.clear();
al.addAll(hs);

http://stackoverflow.com/questions/203984/how-do-i-remove-repeated-elements-from-arraylist

Advertisements

How to Send data from one Fragment to another fragment in android

http://stackoverflow.com/questions/7149802/how-to-transfer-some-data-to-another-fragment

Fragment fragment = new Fragment();
Bundle bundle = new Bundle();
bundle.putInt(key, value);
fragment.setArguments(bundle);
Bundle has put methods for lots of data types. See this

Then in your Fragment, retrieve the data (e.g. in onCreate() method) with:

Bundle bundle = this.getArguments();
int myInt = bundle.getInt(key, defaultValue);