コードはこの例に従って変更されます。関連するファイルを以下に示します。その例の imageicon 部分は必要ないので使用していません。
保留中の.java
public class Pending {
public String title;
public Pending(){
super();
}
public Pending(String title) {
super();
this.title = title;
}
}
PendingAdatapter.java
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;
}
MainActivity.java
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);
データベースのreturnFormname 関数
public ArrayList<String> returnFormName()
{
openOrCreateDatabase();
createlandtTable();
createrefertable();
createassettable();
createofficeusetable();
ArrayList<String> form = new ArrayList<String>();
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;
}