我想从列表视图中获取项目。但是当我尝试单击 listview 时出现错误。一些身体可以帮助我吗?
这是我的课堂活动。
data = new dbHelper(this);
listKeluar = (ListView)findViewById(R.id.listKeluar);
String [] keluar = { data.k_nama, data.m_chiperteks, data.kel_waktu };
int[] k = { R.id.tNama, R.id.tChiper, R.id.tWaktu };
cursor = data.DataPesanKeluar();
SimpleCursorAdapter keluarAdapter = new SimpleCursorAdapter( this, R.layout.baris_keluar, cursor, keluar, k ); //this line my error
listKeluar.setAdapter(keluarAdapter);
listKeluar.setOnItemClickListener( new OnItemClickListener() {
@Override
public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
if(cursor.moveToPosition(arg2)) {
idkeluar = cursor.getString(cursor.getColumnIndex(data.kel_id));//my line error, if i delete this line my listview didn't respon when i click
nama = cursor.getString(cursor.getColumnIndex(data.k_nama));
chiperteks = cursor.getString(cursor.getColumnIndex(data.m_chiperteks));
waktu = cursor.getString(cursor.getColumnIndex(data.kel_waktu));
}
Intent isiPesanKeluar = new Intent();
isiPesanKeluar.setClass(KotakKeluar.this, IsiPesanKeluar.class);
isiPesanKeluar.putExtra("idkeluar", idkeluar);
isiPesanKeluar.putExtra("nama", nama);
isiPesanKeluar.putExtra("chiperteks", chiperteks);
isiPesanKeluar.putExtra("waktu", waktu);
这是我的原木猫
Java.lang.IllegalStateException: get field slot from row 0 col -1 failed
我的方法
public Cursor DataPesanKeluar() {
Cursor c = dba.rawQuery(
" SELECT "
+ kel_id + " AS _id,"
+ e_chiperteks + ","
+ k_nama + ","
+ kel_waktu +
" FROM " + tbPesan + " INNER JOIN " + tbPesanKeluar +
" ON " + tbPesan + "." + p_idpesan + "=" + tbPesanKeluar + "." + kel_idpesan +
" INNER JOIN " + tbEnkrip +
" ON " + tbPesan + "." + p_idenkrip + "=" + tbEnkrip + "." + e_idenkrip +
" INNER JOIN " + tbKontak +
" ON " + tbPesan + "." + p_idkontak + "=" + tbKontak + "." + k_id , null);
return c;
}
我的 baris_keluar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tNama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tChiper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tWaktu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
谢谢你帮助我..问候..