Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send ArrayList into BaseAdapter Android
    primarykey
    data
    text
    <p>I want to display my JSON into gridview, before it.. i displayed my JSON into ListView, and it works. but in BaseAdapter, i don't know how to send my JSON that I have put into ArrayList into Base Adapter</p> <p>so this is my source code :</p> <p>Activity :</p> <pre><code> public class MainActivity extends ListActivity { List AgenList = new ArrayList(); boolean boolStatusKoneksi=true; private ProgressDialog Dialog; protected Context applicationContext; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new AgenAsyncTask().execute(); GridView gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(new AgenAdapter(this)); } public class AgenAsyncTask extends AsyncTask&lt;String, String, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); Dialog = new ProgressDialog(MainActivity.this); Dialog.setMessage("Mohon Tunggu sebentar..."); Dialog.setIndeterminate(false); Dialog.setCancelable(true); Dialog.show(); } protected String doInBackground(String... args) { String url = ("http:10.10.2/selectAgent.htm"); try{ JSONParser j=new JSONParser(); JSONArray jsonArray = j.takeJson(url);; for(int i =0; i&lt;jsonArray.length(); i++){ JSONObject c = jsonArray.getJSONObject(i); HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); if (c.has("atasan")) map.put("atasan", c.get("atasan").toString()); if (c.has("nama_agen")) map.put("nama_agen", c.get("nama_agen").toString()); if (c.has("kode_agen")) map.put("kode_agen", c.get("kode_agen").toString()); if (c.has("no_aaji")) map.put("no_aaji", c.get("no_aaji").toString()); if (c.has("jenis")) map.put("jenis", c.get("jenis").toString()); AgenList.add(map); } } catch (JSONException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String file_url) { } } </code></pre> <p>This is my BaseAdapter :</p> <pre><code> public class AgenAdapter extends BaseAdapter { public AgenAdapter(MainActivity mainActivity) { } @Override public int getCount() { // TODO Auto-generated method stub return 0; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater layout = getLayoutInflater(); View view= layout.inflate(R.layout.list_item,parent,false); TextView ATASAN = (TextView) findViewById(R.id.atasan); TextView NAMA_AGEN= (TextView) findViewById(R.id.nama_agen); TextView KODE_AGEN= (TextView) findViewById(R.id.kode_agen); TextView NO_AAJI= (TextView) findViewById(R.id.no_aaji); TextView JENIS= (TextView) findViewById(R.id.jenis); return view; } } } </code></pre> <p>As you see, i have ArrayList named as = AgenList but i haven't put it into my BaseAdapter.</p>
    singulars
    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.
 

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