[英]Android Studio Swipe Refresh
我只是想知道是否有人可以帮助我,我试图添加滑动刷新功能,但看不到我要去哪里,我只是收到错误消息无法解析符号mySwipeRefreshLayout
这是代码。 谢谢
public class eventsListActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
mySwipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshList();
}
}
public class eventsListActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {
mySwipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refreshList();
}
}
XML代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_events_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.parse.fypPlannr.eventsListActivity"
android:background="#24B14D">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/Swiper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:id="@+id/eventList"
android:layout_below="@+id/createEvent"
android:textColor="@android:color/holo_orange_light"/>
</android.support.v4.widget.SwipeRefreshLayout>
<Button
android:text="Map View"
android:layout_height="wrap_content"
android:id="@+id/mapButton"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#029789"
android:textColor="#ffffbb33"
android:onClick="mapView" />
<Button
android:text="Log Out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/logOut"
android:onClick="logOut"
android:background="#029789"
android:textColor="#ffffbb33"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/mapButton"
android:layout_toStartOf="@+id/mapButton" />
<Button
android:text="Create Event"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/createEvent"
android:onClick="createEvent"
android:background="#04988a"
android:textColor="#ffffbb33"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/mapButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_events_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.parse.fypPlannr.eventsListActivity"
android:background="#24B14D">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/Swiper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:id="@+id/eventList"
android:layout_below="@+id/createEvent"
android:textColor="@android:color/holo_orange_light"/>
</android.support.v4.widget.SwipeRefreshLayout>
<Button
android:text="Map View"
android:layout_height="wrap_content"
android:id="@+id/mapButton"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#029789"
android:textColor="#ffffbb33"
android:onClick="mapView" />
<Button
android:text="Log Out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/logOut"
android:onClick="logOut"
android:background="#029789"
android:textColor="#ffffbb33"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/mapButton"
android:layout_toStartOf="@+id/mapButton" />
<Button
android:text="Create Event"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/createEvent"
android:onClick="createEvent"
android:background="#04988a"
android:textColor="#ffffbb33"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/mapButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
http://pastebin.com/u72WtQ3y的Java代码
您不需要使用工具SwipeRefreshLayout.OnRefreshListener。
而且我还没有发现其他问题。 也许refreshList()中有错误; 方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.