Android SwipeRefreshLayout指标

时间:2016-01-15 11:09:41

标签: android swiperefreshlayout


我正在开发Android应用程序,它非常复杂,但问题是具体的。 我有一个ListFragment。他的布局在SwipeRefreshLayout中包含一个自定义ListView。 这是我第一次使用SwipeRefreshLayout,所以我在示例应用程序中尝试过,一切正常。 问题是,当我向下滚动以刷新示例应用程序时,我得到了一个漂亮的滚动圈,说我正在加载,但如果我在真实的应用程序中做同样的事情,我得到一个彩色条,在动作栏,可以做一些动画。 我想不同的动画取决于某些样式或目标配置,但我无法理解究竟是什么。 我想在我的真实应用中也有滚动圈,或者至少理解为什么它会有所不同......
有没有人有想法?
非常感谢!

编辑:
如我所知,我将粘贴清单和部分代码。

<manifest xm

lns:android="http://schemas.android.com/apk/res/android"
     package="com.mindInformatica.apptc20.commons"
     android:versionCode="1"android:versionName="1.0">
     <uses-sdk android:minSdkVersion="14"
      android:targetSdkVersion="22"/>
    <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="com.mindInformatica.apptc20.activities.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.mindInformatica.apptc20.activities.permission.C2D_MESSAGE" />

        <application android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/ic_launcher">

        <!-- main activity -->
        <activity
            android:name="com.mindInformatica.apptc20.activities.PreLoginActivity"
            android:windowSoftInputMode=""
            android:label="@string/app_name"
            android:screenOrientation="nosensor"
            android:noHistory="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>


       <!-- activity that contains swiperefershlayout -->
        <activity
            android:name="com.mindInformatica.apptc20.activities.AppActivity"
            android:windowSoftInputMode=""
            android:label="@string/app_name"
            android:screenOrientation="nosensor" >
        </activity>
      <!— many others activities —>

        <meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value=“….”/>
        <provider android:name="android.support.v4.content.FileProvider"
            android:authorities="com.mindInformatica.apptc20.activities"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>

        <receiver
            android:name="com.mindInformatica.apptc20.notifiche_push.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.mindInformatica.apptc20.activities" />
            </intent-filter>
        </receiver>
        <service android:name="com.mindInformatica.apptc20.notifiche_push.GcmIntentService" />
                <receiver android:name="com.mindInformatica.apptc20.notifiche_push.SecondaryBroadcastReceiver" >
            <intent-filter android:priority="1" >
                <action android:name="com.mindInformatica.apptc20.commons.GOT_PUSH" >
                </action>
            </intent-filter>         
        </receiver>        
     </application>

</manifest>

布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/swiperefresh"
   android:layout_width="match_parent"
   android:layout_height="match_parent">     
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/header" >
        <FrameLayout android:id="@+id/fragment_container0"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true">
        </FrameLayout>
     </RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout> </RelativeLayout>

在AppActivity的“onCreate”方法中我这样做:

    SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    mSwipeRefreshLayout.setColorScheme( android.R.color.holo_blue_bright, android.R.color.holo_green_dark, android.R.color.holo_orange_dark, android.R.color.holo_purple);
    Log.d("SECTION_FRAGMENT", "settato swipe");
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
            Log.d("SECTION_FRAGMENT", "on refresh");
      }
  });

0 个答案:

没有答案