Note that there are some explanatory texts on larger screens.

plurals
  1. POto display arraylist in list view
    primarykey
    data
    text
    <p>The code is changed according to this <a href="http://www.ezzylearning.com/tutorial.aspx?tid=1763429" rel="nofollow">example</a>. The relevant files are specified below. I am not using the imageicon part of that example because I don't need it.</p> <p><strong>Pending.java</strong></p> <pre><code>public class Pending { public String title; public Pending(){ super(); } public Pending(String title) { super(); this.title = title; } } </code></pre> <p><strong>PendingAdatapter.java</strong></p> <pre><code>public PendingAdapter(Context context, int layoutResourceId, Pending[] data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = data; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; PendingHolder holder = null; if(row == null) { LayoutInflater inflater = ((Activity)context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new PendingHolder(); holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle); row.setTag(holder); } else { holder = (PendingHolder)row.getTag(); } Pending weather = data[position]; holder.txtTitle.setText(weather.title); return row; } static class PendingHolder { TextView txtTitle; } </code></pre> <p><strong>MainActivity.java</strong></p> <pre><code>WayDataBase way1=new WayDataBase(Dashboard.this); Pending weather_data[] = new Pending[] { new Pending(way1.returnFormName().toString()) }; PendingAdapter adapter = new PendingAdapter(this, R.layout.listview_item_row, weather_data); lstvw=(ListView)findViewById(R.id.forms_list); View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null); lstvw.addHeaderView(header); lstvw.setAdapter(adapter); </code></pre> <p>the <strong>returnFormname function of the database</strong></p> <pre><code>public ArrayList&lt;String&gt; returnFormName() { openOrCreateDatabase(); createlandtTable(); createrefertable(); createassettable(); createofficeusetable(); ArrayList&lt;String&gt; form = new ArrayList&lt;String&gt;(); int appcount=0,refercount=0,assetcount=0,officecount=0; appcount=db.rawQuery("select * from "+TableNameis+";" ,null).getCount(); refercount=db.rawQuery("select * from "+ReferenceTable+";" ,null).getCount(); assetcount=db.rawQuery("select * from "+AssetTable+";" ,null).getCount(); officecount=db.rawQuery("select * from "+OfficeUse+";" ,null).getCount(); if(appcount==0) { form.add("Applicant"); } if(refercount==0) { form.add("Reference"); } if(assetcount==0) { form.add("Asset Details"); } if(officecount==0) { form.add("Office Use"); } return form; } </code></pre>
    singulars
    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.
 

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