Reputation: 141
I got a list from console.log(js) using onConsoleMessage from webChromeClient
158 word
i did
ArrayList<String> list = new ArrayList<String>();
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,list);
list.add(a);
simpleList.setAdapter(adapter);
a is a string that have that list
i always got one item which is the last one U.S. Virgin Islands
in the listview
How can i fix that, i'm really tired trying many things without success :/
Upvotes: 1
Views: 226
Reputation: 159
Use a for each
loop to get all the elements in a list:
e.g. for(String list: a)
all the items are
stored in arrayList
, then
ArrayList<String> list = new ArrayList<String>();
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,list);
list.add(ss);
simpleList.setAdapter(adapter);
'a' is a String type array.
Upvotes: 0
Reputation: 159
ArrayList<String> list = new ArrayList<String>();
ArrayAdapter<String> adapter=new ArrayAdapter<String>
(getContext(), android.R.layout.simple_list_item_1,list);
list.addAll(Arrays.asList(a));
simpleList.setAdapter(adapter);
Where 'a' is a String type array.
Upvotes: 1
Reputation: 3268
In one variable you should get number of data in adapter. Then in a simple while loop you will have data which are saved in shared preferences. You can toast it, see it in log or add it to an Arraylist.
int j = adapter.getCount();
int i = 0;
while (i < j) {
Log.d("abc", adapter.getItem(i));
i++;
}
Upvotes: 0