Search in sources :

Example 1 with Result

use of com.novoda.model.Result in project android-demos by novoda.

the class JsonRequest method onResume.

@Override
protected void onResume() {
    super.onResume();
    Toast.makeText(this, "Querying droidcon on Twitter", Toast.LENGTH_SHORT).show();
    Reader reader = new InputStreamReader(retrieveStream(url));
    SearchResponse response = new Gson().fromJson(reader, SearchResponse.class);
    List<String> searches = new ArrayList<String>();
    Iterator<Result> i = response.results.iterator();
    while (i.hasNext()) {
        Result res = (Result) i.next();
        searches.add(res.text);
    }
    ListView v = (ListView) findViewById(R.id.list);
    v.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, searches.toArray(new String[searches.size()])));
}
Also used : ListView(android.widget.ListView) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Gson(com.google.gson.Gson) SearchResponse(com.novoda.model.SearchResponse) Result(com.novoda.model.Result)

Aggregations

ListView (android.widget.ListView)1 Gson (com.google.gson.Gson)1 Result (com.novoda.model.Result)1 SearchResponse (com.novoda.model.SearchResponse)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1