2015-08-22 20 views
6

Uygulamamda Yenile'ye Çek uygulamayı denedim.ScrollView/ListView kullanmadan Yenilemek için Pull kullanabilir miyim?

xml kodunu android.support.v4.widget.SwipeRefreshLayout ile kapattım ve çalışıyor, ancak GUI iyi görünmüyor.

ben aşağı çekin, ben sağ, benim tanımlanan renklerle düzenli animasyonlu çevre simgesine görmelisiniz ?, ama boş bir daire değil, renkleriyle dönüm tek olması gerektiği gibi olarak görüyoruz. Ayrıca, onunla "oynayamayacağım" ve çekip aldıktan sonra bile bir süre bekletemiyorum, bir saniye boyunca (ne yaparsa yapsın) kaybolur ve sonra kaybolur.

Bunun nedeni, bunun yerine ListView ancak LinearLayout kullanmıyorum.

Ne düşünüyorsunuz?

Kodu:

XML:

<android.support.v4.widget.SwipeRefreshLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/swipe"> 

    <LinearLayout 
     android:layout_height="match_parent" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:background="#7B68EE" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     tools:context=".HomeActivity"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/loin" 
     android:orientation="horizontal"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="@string/welcome" 
      android:textColor="#B0C4DE" 
      android:id="@+id/welcomeBackID" 
      android:layout_alignParentTop="true" 
      android:layout_alignRight="@+id/webViewCurren" 
      android:layout_alignEnd="@+id/webViewCurren" /> 

     .... 

</android.support.v4.widget.SwipeRefreshLayout> 

Java:

public class HomeActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener { 

    SwipeRefreshLayout mSwipeRefreshLayout; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 

     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_home); 

     mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe); 
     mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_light, 
       android.R.color.holo_blue_bright, 
       android.R.color.holo_orange_light, 
       android.R.color.holo_red_light); 
     mSwipeRefreshLayout.setOnRefreshListener(this); 

    @Override 
    public void onRefresh() { 
     Toast.makeText(this, "Refresh", Toast.LENGTH_SHORT).show(); 
     sharedPrefEditor.putString("coordinateX", "34.7"); 
     sharedPrefEditor.putString("coordinateY", "32.5"); 
     sharedPrefEditor.putString("saved", "false"); 
     sharedPrefEditor.commit(); 

     new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       mSwipeRefreshLayout.setRefreshing(false); 
      } 
     }, 3000); 
    } 
} 

cevap

0

SwipeRefreshLayout renk düzenini değiştirmeyi deneyin. onRefresh(), Yürütme tamamlandığında sadece kadar

swipeRefreshLayout.setColorSchemeColors(
    Color.RED, Color.GREEN, Color.BLUE, Color.CYAN); 

Ayrıca SwipeRefreshLayout görünür olacaktır.

İlgili konular