0
只是想知道是否有人可以帮助我这个,我想添加一个刷卡刷新功能,我不能看到我要去哪里错了,我只是得到错误信息无法解析符号mySwipeRefreshLayoutAndroid工作室刷卡刷新
继承人的代码。由于
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
我编辑了您的文章,它将会显示一会儿。我在你的文章中发布了代码。确保你对代码进行了更好的解释并发布你的logcat,并且你可以删除指向某个webiste外部的stackoverflow的链接。 – Yupi
您需要在使用Java之前声明一个变量。您的'mySwipeRefreshLayout'尚未在当前类或任何超类中声明。在尝试Android之前,请花一些时间在[Java Tutorials](https://docs.oracle.com/javase/tutorial/)上工作,否则从现在起,您将遇到各种难题。 –