リストビュー「ListView画面」にレコードをリストする2つの画面と 、特定のレコードを表示するために使用される「特定のレコード画面」の2つの画面があります。リストビューの行のデータを保持するために使用される grid_item.xml を使用しています。grid_item.xml は以下のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/col1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:width="50dip"
/>
<TextView android:id="@+id/col2"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:width="200dip"
/>
<TextView android:id="@+id/col3"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:width="200dip"
/>
<TextView android:id="@+id/col4"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:width="200dip"
/>
<ImageView android:id="@+id/editimage"
android:layout_width="30dip"
android:layout_height="30dip"
android:background="@drawable/edit"
android:clickable="true"
android:onClick="ClickHandlerForEditImage"
/>
</LinearLayout>
クリックすると「特定の記録画面」を開くために使用される ImageView があります。「ClickHandlerForEditImage」イベントをそのイメージビューに添付しました (上記の xml の最後の数行を参照)。
コード:
public void ClickHandlerForEditImage(View v)
{
LinearLayout vwParentRow = (LinearLayout)v.getParent();
TextView txtId = (TextView)vwParentRow.getChildAt(0);
long rowId = CommonMethods.GetLong(txtId);
//Log.d("Inspection", "onItemClick Postion "+ rowId);
//vwParentRow.refreshDrawableState();
if(rowId > 0)
{
Intent intent = new Intent("com.moftak.db.DatabasesActivity");
intent.putExtra("RecordId", rowId);
startActivity(intent);
}
}
問題は、正常に動作し、「特定のレコード画面」が開かれることですが、「戻るボタン」を押すと「ListView画面」が表示されますが、ListView(またはListViewアイテム)が消えます。
誰か助けてくれませんか。貴重なお時間とご協力に感謝いたします。