setOnTouchListener header listview android无法正常工作

时间:2014-04-04 04:40:44

标签: android listview

我有一个ListView,我为ListView添加了标题,但是当我使用setOnTouchListener作为标题时,它似乎无效。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.event_list, container, false);
    btnLoadMore = inflater.inflate(R.layout.event_list_footer, null, false);
    listEvent = (ListView) rootView.findViewById(R.id.list_event);
    mHeader = inflater.inflate(R.layout.event_list_header, null, false);
    listEvent.addHeaderView(mHeader,null, false);
    listEvent.addFooterView(btnLoadMore);
    mHeader.setOnTouchListener(mActivitySwipeMotion);
    return rootView;
}

和event_list_header.xml

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ImageView
    android:id="@+id/image_banner"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:src="@drawable/banner_evenlist" />

1 个答案:

答案 0 :(得分:0)

试试这个

enter code here

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/myList"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    Then add the header layout to your ListView:

View header = (View)getLayoutInflater().inflate(R.layout.header,null);
mList.addHeaderView(header);