1
我有這樣的佈局基礎挖掘setOnRefreshListener甚至被稱爲:安卓:如果我在我的ListView外
<RelativeLayout
android:id="@+id/list_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/list_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
在這個片段創作,我添加了一個具體名單:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:divider="@color/list_divider"
android:dividerHeight="1px" />
所以當我在紅色區域(列表視圖外)挖掘,聽者被稱爲:
mSwipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
...
}
});
那麼,爲什麼這個監聽者被調用,我可以避免這種行爲?
變化'機器人:layout_height = 「WRAP_CONTENT」''到機器人:layout_height = 「match_parent」'或SwipeRefreshLayout使用'爲高度 –
SwipeRefresh設定wrap_content'到matchcontent,使得紅色區域是它 – user6547359
'機器人部分:layout_height =「wrap_content」' –