【发布时间】:2014-05-04 20:23:54
【问题描述】:
我正在尝试将ActionBar-PushToRefresh 添加到我的项目中。我已经按照 Chris Banes Github 那里的说明进行操作:Github ActionBar-PullToRefresh
这是我想要启用PullToRefresh 功能的观点:
<uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ptr_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your content, here we're using a ScrollView -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="PULLTOREFRESH THE VIEW"
android:id="@+id/textView1" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout>
这是我显示视图的 Activity:
package com.Test.pulltorefresh;
import android.app.Activity;
import android.os.Bundle;
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh;
import uk.co.senab.actionbarpulltorefresh.library.Options;
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout;
public class MainActivity extends Activity {
private PullToRefreshLayout mPullToRefreshLayout;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Now find the PullToRefreshLayout to setup
mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);
// Now setup the PullToRefreshLayout
ActionBarPullToRefresh.from(this)
// Mark All Children as pullable
.allChildrenArePullable()
// Set the OnRefreshListener
//.listener(this)
// Finally commit the setup to our PullToRefreshLayout
.setup(mPullToRefreshLayout);
}
}
当我启动我的应用程序时,我得到了空白视图,但是当我尝试 PushToRefresh 我的视图时没有任何反应。有人可以告诉我如何解决它,我知道我错过了一些东西。谢谢。
【问题讨论】:
标签: java android android-actionbar pull-to-refresh