0

I was store some values as a comma separated string in Sq lite database. Now i want to getting that values from database to list view. But problem is, the comma separated string is directly visible in list view, i want to split that string and display in list view. I am very confusing because, i used array list to get comma separated from DB, I don't know how to split that string in array list and display list view?

 how to split string from Arraylist by comma and get that stringd to listview.
venki
  • 77
  • 2
  • 10

1 Answers1

1
String temp = arrayValues.toString());
String qusChoice = temp.substring(1,temp.length() - 1);
String[] arrayList = qusChoice.split(",");
ArrayList choiceList = new ArrayList<String>();
for (int i = 0; i < arrayList.length; i++) {

         choiceList.add(arrayList[i]);
    }

    ListView listChoice = (ListView)findViewById(R.id.list_choice);
    adapter = new ChoiceAdapter(MainActivity.this,R.layout.custom_list,choiceList );
    listChoice.setAdapter(adapter);
Jai Rajesh
  • 939
  • 5
  • 18
  • thank you rajesh, here i want to display this splitted strings into inflated xml file text view. means if the splitted strings are two, then first string display in first row textview, second string will display in second row textview. give me an idea – venki Dec 29 '14 at 14:19
  • if i value is odd number assign first row text view and i values is even means assign second row text view. may be it will help you – Jai Rajesh Dec 30 '14 at 05:18