Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class ReadJSONFeedTask extends AsyncTask <String, Void, String>
- {
- protected String doInBackground(String...urls)
- {
- Log.d("JSON", "number of surveys in feed 3");
- return readJSONFeed(urls[0]);
- }
- protected void onPostExecute(String result)
- {
- try{
- Log.d("JSON", "Result file - " + result);
- JSONArray jsonArray = new JSONArray(result);
- for(int i=0; i<ksonArray.length(); i++)
- {
- Log.d("JSON", "result file - " + 1);
- JSONObject jsonObject3 = jsonArray.getJSONObject(i);
- Log.d("data json", jsonArray.getJSONObject(i).toString());
- ab = new ArrayBook(jsonObject3.getString("book_id"), jsonObject3.getString("title"), jsonObject3.getString("author_code"));
- Toast.makeText(getBaseContext(), ab.getAuthor().toString(), Toast.LENGTH_SHORT).show();
- dataBook.add(ab);
- }
- adapter = new CustomAdapter (getApplicationContext (), dataBook);
- lvi.setAdapter(adapter);
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- protected void onCreate(Bundle savedInstanceState){
- super.onCreate(savedInstanceState);
- dataBook = new ArrayList<ArrayBook>();
- setContentView(R.layout.activity_main);
- lvi = (ListView) findViewById(R.id.list);
- Log.d("JSON", "number of surveys in feed");
- new ReadJSONFeedTask().execute("http://yustinuswidya.com/senghansun.json");
- Log.d("JSON", "number of surveys in feed 2");
- adapter = new CustomAdapter(getApplicationContext(), dataBook);
- lvi.setAdapter(adapter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement