2011-10-14 53 views
0

回來後我有兩個屏幕的其中一個列表中的記錄在ListView 「的ListView屏幕」 &這是用於顯示一個特定的記錄「特定記錄屏幕」第二。 我正在使用grid_item.xml,它用於在列表視圖中保存一行數據。 的grid_item.xml低於:的ListView消失從活動

<?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項目)消失。

有人可以幫助我。在此先感謝您的寶貴時間&幫助。

回答

1

我找到了一個解決方案... 覆蓋onRestart()&在這裏添加你的代碼,這是填充列表在我的情況下查看它是LoadInspection()。

@Override 
public void onRestart() 
{ 
    super.onRestart(); 
    LoadInspections(); 
} 

有人可以評論列表視圖的這種行爲嗎?謝謝。

+0

這是一流的男人,非常感謝:) – user788511