2

can any one help me to display set of results in my app in a list view. i got the following

codeList<Result> results = response.results;

        for (Result result : results) {
            //Toast.makeText(this, result.fromUser, Toast.LENGTH_SHORT).show();
            Toast.makeText(this, result.text, Toast.LENGTH_LONG).show();
            //String[] ch=getResources().getString(result.text);//result.text;
            //adapter = new ArrayAdapter<String>(this,R.layout.mainlist,result.text);
            //SimpleArrayAdapter adapter = new SimpleArrayAdapter(this, result.text);

            setListAdapter(adapter);
        }

i want to show result.text in a listview for each value. i tried everything commented in the code, but not getting. please help me.

1

3 Answers 3

1

with this short snippet of code it is hard to know what the problem might be,

possibly this will help http://developer.android.com/resources/tutorials/views/hello-listview.html

after setListAdapter(adapter); try adding adapter.notifyDataSetChanged() or alternatively try adapter.setNotifyOnChange(true) just after initializing the adapter this might solve your issue if it is what i think it is. else post more of your code

Sign up to request clarification or add additional context in comments.

Comments

1

You can use **ExpandableListView**

enter image description here

Refer : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList3.html

Comments

0

1) extend ArrayAdapter with your custom class:

class MyAdapter extends ArrayAdapter<Result> 

2) create xml for layout of each row, eg. row.xml and set it in constructor of your adapter:

    MyAdapter(Activity context, int resourceId, ArrayList<Result>
    mResults) {             
      super(context, R.layout.row, mResults);
 }

3) in getView method of your adapter fill apropriate field with your result.text
4) set list adapter to your custom adapter

   MyAdapter adapter = new MyAdapter(this, 0, mResults);
  setListAdapter(adapter);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.