2016-07-12 4 views
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() { 
     ... 
    } 
}); 

enter image description here

なぜ、このリスナーが呼び出されたのですか?その動作を回避できますか?

+0

変更 'アンドロイド:アンドロイド'へlayout_height = "wrap_content" ':layout_height = "match_parent"'又はSwipeRefreshLayout赤色領域がそれの一部 –

+0

ためwrap_content'はSwipeRefreshは、matchcontentに設定されている'使用:layout_height = "wrap_content" ' – user6547359

+0

'アンドロイドになるように高さ –

答えて

0
<android.support.v4.widget.SwipeRefreshLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/swipe_list_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <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" /> 

</android.support.v4.widget.SwipeRefreshLayout> 

<RelativeLayout 
    android:id="@+id/list_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

     <FrameLayout 
      android:id="@+id/list_content" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"    
      android:background="@color/background" /> 

</RelativeLayout> 

使用リストビューを含む全体の断片にリフレッシュするためにスワイプを実装しました。この 。

+0

あなたの投稿は理解できませんか? – anthony

関連する問題