【问题标题】:ActionBar-PullToRefresh nothing happensActionBar-PullToRefresh 没有任何反应
【发布时间】: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


    【解决方案1】:

    也许你已经实现了这个功能,但是在上面的代码中,你已经注释掉了定义拉取视图的动作的行。

    //.listener(this)
    

    你应该取消注释这一行并定义监听器方法,当视图被拉出时应该被调用。

    【讨论】:

      【解决方案2】:

      我可能有点偏心,但是... you could consider using this

      【讨论】:

      • 但是我还是想用 ActionBar-PullToRefresh 来做一个好的开始,有人可以帮帮我吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      相关资源
      最近更新 更多