Cim*_*man 10 android progress-bar android-styles
我android.support.v4.widget.SwipeRefreshLayout在我的Android应用中使用.它包裹了一个ListView.列表视图的内容是从服务器下载的.
当用户向下滑动以从服务器重新加载数据时,将显示进度视图.进度视图看起来像一个在动画期间增长和缩小的圆圈.看来这个进度视图的风格不能定制太多.但是,我内置的风格很好.
我还在初始数据加载期间显示相同的进度动画.这可以通过致电来实现mySwipeRefreshLayout.setRefreshing(true).那也很好.
但是,我想通过整个应用程序显示相同的进度指示.考虑例如看起来像带有提交按钮的表单的另一个活动.这种形式的活动既没有ListView也没有SwipeRefreshLayout.在将提交的数据传输到服务器时,应显示一些进度指示.我想在SwipeRefreshLayout中显示具有相同动画的进度条.
是否有一种简单而干净的方法来为a SwipeRefreshLayout和表单活动提供相同的进度指示器,该表单活动不包含任何列表视图和刷新布局,并且不支持任何滑动手势?
谢谢.
Dha*_*mar 10
但是,我想通过整个应用程序显示相同的进度指示.考虑例如看起来像带有提交按钮的表单的另一个活动.此表单活动中既没有ListView也没有SwipeRefreshLayout.在将提交的数据传输到服务器时,应显示一些进度指示.我想在SwipeRefreshLayout中显示具有相同动画的进度条.
是的,您可以使用SwipeRefreshLayout显示ProgressDialog按钮单击时.检查下面.
我已经SwipeRefreshLayout在我的布局文件中添加了仍然没有ListView或ScrollView.就像下面一样
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="niu.com.djandroid.jdroid.androidstack.MainActivity"
tools:showIn="@layout/activity_main">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="54dp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
现在我曾经在我的活动AsyncTask中表现出来SwipeRefreshLayout.也mSwipeRefreshLayout.setOnRefreshListener(null)用来停止滑动手势.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(null);
((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// mSwipeRefreshLayout.setRefreshing(true);
// call AsyncTask
new LongOperation().execute("");
}
});
}
private class LongOperation extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
for (int i = 0; i < 5; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.interrupted();
}
}
return "Executed";
}
@Override
protected void onPostExecute(String result) {
// stop mSwipeRefreshLayout
mSwipeRefreshLayout.setRefreshing(false);
}
@Override
protected void onPreExecute() {
// start mSwipeRefreshLayout
mSwipeRefreshLayout.setRefreshing(true);
}
@Override
protected void onProgressUpdate(Void... values) {
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
你可以使用Github的SwipeRefreshLayoutBottom库.和...一样swiperefreshlayout.检查下面
| 归档时间: |
|
| 查看次数: |
6114 次 |
| 最近记录: |