0
我有一個帶有標題面板和列表視圖的佈局。從其父視圖組中刪除視圖時禁止在列表視圖中重新加載項目
這是佈局。
<?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"
android:id="@+id/mainFragmentLayout">
<RelativeLayout
android:id="@+id/header"
android:background="@drawable/upper_panel"
android:layout_height="40dp"
android:layout_width="fill_parent">
<TextView android:id="@+id/news_label"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:gravity="left"
android:text="@string/news_label"
android:textSize="15sp"
android:textStyle="bold"
android:layout_marginLeft="54dp"
android:textColor="@color/white"
/>
<Button android:id="@+id/refreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/btm_refresh"
android:layout_centerVertical="true"
android:layout_marginRight="8dp"
/>
</RelativeLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="120"
android:id="@+id/feedMeMore"
android:fastScrollEnabled="false"
android:layout_gravity="center"/>
在onTouchListener予刪除和添加RelativeLayot報頭。
public boolean onTouch(View view, MotionEvent motionEvent) {
int action=motionEvent.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
startY = motionEvent.getY();
break;
case MotionEvent.ACTION_MOVE:
float nowY = motionEvent.getY();
if (startY - nowY > 10)
{
if (mainLayout.indexOfChild(headerView) >= 0)
mainLayout.removeView(headerView);
}
else if (startY - nowY < - 100)
{
if (mainLayout.indexOfChild(headerView) < 0)
mainLayout.addView(headerView, 0);
}
}
break;
}
return false;
}
當標題被刪除時,listview中的所有顯示項都被重新加載。 我有一個圖像和文本,這是從網站加載,每次它重新加載文本和圖像。
如何關閉此重新加載?
謝謝。但是當我刪除標題時,我需要將listview擴展到全屏。 – TpoM6oH