ListView disappears after return from activity
I have two screens the one which list the records in a listview "ListView Screen" & the second which is used for showing a specific record "specific record screen". I am using grid_item.xml, which is used to hold the data of a row in the listview. the grid_item.xml is below:
<?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/c开发者_Go百科ol4"
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>
There is an ImageView which is used to open the "specific record screen" when its clicked. I have attached the "ClickHandlerForEditImage" event to that imageview (see the last few lines of the above xml).
The code:
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);
}
}
Now the problem is that it works fine, the "specific record screen" is opened, but when i press the "back button", the "ListView Screen" is displayed but the ListView (Or the ListView Items) disappears.
Can somebody help me. Thanks in advance for your valuable time & help.
i found a solution... Override the onRestart() & add your code here which is populating the list View in my case it is the LoadInspection().
@Override
public void onRestart()
{
super.onRestart();
LoadInspections();
}
Can somebody comment on this behavior of List View? Thanks.
精彩评论