Android Studio刷卡刷新

时间:2017-02-03 22:58:15

标签: java android refresh swipe

只是想知道是否有人可以帮我这个,我正在尝试添加刷卡刷新功能,我无法看到我出错的地方,我只是得到错误信息无法解析符号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代码

http://pastebin.com/9KnYhJLp XML

1 个答案:

答案 0 :(得分:0)

您不需要使用工具SwipeRefreshLayout.OnRefreshListener。

我没有发现另一个问题。也许在refreshList()中有错误;方法