Note that there are some explanatory texts on larger screens.

plurals
  1. POworking as java application not as android application
    primarykey
    data
    text
    <p>I am reading a json file from a local drive and making it as gson. And it's working as a java application.</p> <pre><code> Gson gson = new Gson(); BufferedReader br = new BufferedReader(new FileReader("D:\\AircraftService.json")); DataObject[] obj = gson.fromJson(br, DataObject[].class); System.out.println("The object length is: " + obj.length); for(int i = 0; i&lt;obj.length ; i++ ) { System.out.println(obj[i].AC + " " + obj[i].Fleet + " " + obj[i].SubFleet); } </code></pre> <p>Using this I am trying to populate an android list </p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listplaceholder); ListView lv= (ListView)findViewById(R.id.list); Gson gson = new Gson(); BufferedReader br = new BufferedReader(new FileReader("D:\\AircraftService.json")); DataObject[] obj = gson.fromJson(br, DataObject[].class); List&lt;HashMap&lt;String, String&gt;&gt; fillMaps = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); for(int i=0 ; i&lt;obj.length ; i++){ HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put("AC", obj[i].AC); map.put("Fleet", obj[i].Fleet ); map.put("SubFleet", obj[i].SubFleet ); fillMaps.add(map); } SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.main, new String[] {"AC", "Fleet"}, new int[] {R.id.ac, R.id.fleet}); lv.setAdapter(adapter); } </code></pre> <p>It's not able to populate the obj. Ouput is blank. Can you tell me where I am going wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload