I am new to Android development. I am using ArrayList to store country names, then to display the country name in ListView, but the value are assign wrong, below attached the picture for your reference. How to display a order like Afghanistan (1st cell), Aland Island (2nd cell) etc…
Thanks
I tried the below code:
private ArrayList<String> Countryname = new ArrayList<String>();
String dataAll;
lv1 = (ListView)findViewById(R.id.ListView01);
for(int i=0;i<allTitles.getLength();i++) {
dataAll+=allTitles.item(i).getChildNodes().item(0).getNodeValue()+"\n";
this.Countryname.add(dataAll);
}
lv1.setAdapter(new ArrayAdapter<String>(SampleAndroidActivity.
this,android.R.layout.simple_list_item_1, Countryname));

try this:
Because you are appending new values in dataAll so remove “+” sign from front.