データベースから取得された配列アダプターを使用してテキストを含むリストビューがあります。正常に動作します。しかし、データベースに保存されている画像パスがあり、カーソルを使用して画像とテキストビューを含むカスタムリストに表示したい. 誰でも例を挙げて私に提案します
public class SingleItem extends Activity {
DatabaseHelper db;
Cursor c;
private CustomAdapter Adapter;
protected Object mActionMode;
String[] Phno,Description;
int[] Amount;
int j=0,pos;
private ArrayList<String> arrayList = new ArrayList<String>();
private SQLiteDatabase expenses;
ListView detail;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.singleitem);
TextView item=(TextView) findViewById(R.id.textView1);
detail=(ListView) findViewById(R.id.listView1);
Intent i=getIntent();
String st=i.getStringExtra("Bill");
item.setText(st);
try {
db = new DatabaseHelper(this);
//Open the database
expenses = db.getWritableDatabase();
c = expenses.rawQuery("SELECT * FROM Details where Name like"+"'%"+st+"%'", null);
Phno=new String[c.getCount()];
Description=new String[c.getCount()];
Amount=new int[c.getCount()];
if (c != null ) {
if (c.moveToFirst()) {
do {
Phno[j] = c.getString(c.getColumnIndex("Phno"));
//String Name = c.getString(c.getColumnIndex("Name"));
Description[j] = c.getString(c.getColumnIndex("Description"));
Amount[j] = c.getInt(c.getColumnIndex("Amount"));
String Date = c.getString(c.getColumnIndex("Date"));
//String Image=c.getString(c.getColumnIndex("Image"));
arrayList.add("Description :"+Description[j]+"\n"+
"Amount : " +Amount[j] +"\n"+
"Date :"+Date );
j++;
}while (c.moveToNext());
}
}
} catch (SQLiteException se ) {
Log.e(getClass().getSimpleName(),
"Could not create or " +"Open the database");
} finally {
if (expenses != null)
expenses.close();
}
detail.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arrayList));
detail.setOnItemLongClickListener(new OnItemLongClickListener() {
// Called when the user long-clicks on someView
public boolean onItemLongClick (AdapterView parent, View view, int position, long id) {
pos=position;
if (mActionMode != null) {
return false;
}
// Start the CAB using the ActionMode.Callback defined above
mActionMode = SingleItem.this.startActionMode(mActionModeCallback);
view.setSelected(true);
return true;
}
});
}