【发布时间】:2014-12-17 06:46:29
【问题描述】:
我正在开发一个应用程序。我的布局如下:
代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg" >
<ImageView
android:id="@+id/imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:contentDescription="@string/app_name"
android:src="@drawable/logo" />
<ImageView
android:id="@+id/imageview_1"
android:layout_width="120sp"
android:layout_height="120sp"
android:layout_below="@+id/imageview"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:background="@drawable/appicon"
android:contentDescription="@string/app_name" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageview_1"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/progressBar"
android:layout_centerHorizontal="true"
android:textColor="@android:color/white"
android:layout_margin="20sp" />
</RelativeLayout>
现在我的 java 代码流程为:
onCreate => Async task 1
doInBackground of Async task 1 => function 1 => from function 1 to function 2 => from function 2 to function 3 = > from function 3 return.
from onPost of Async task 1 => call Async task 2
doInBackground of Async task 2 => function a => from function a to function b => from function b to return.
from onPost of Async task 2 => call Async task 3
doInBackground of Async task 3 => function x => from function x to function y => from function y to return.
这是我的应用程序的固定流程。
问题是:当我的活动运行时,进度条运行良好,但当异步任务执行开始时,进度条停止移动。
我尝试了链接中的解决方案:
但是输出是一样的。
我还想在异步 1 上更改“运行时更改文本视图”的文本,然后在异步 2 和异步 3 上再次更改。
请建议我如何处理您的宝贵建议。如果需要,请回复以进一步澄清问题。
【问题讨论】:
-
显示进度条代码
-
@manojFedge 只是一个问题,为什么不使用 1 个 asyncTask 执行所有工作(调用所有函数)?
-
您在 cat 日志中看到任何错误?如果您点击了该链接,那么您的代码流中的某些对象可能会被锁定。
-
我没有收到任何错误。
-
@Yazan :因为我在函数中执行的任务是可重用的。所以我不能异步编写整个代码。这就是app的需要。
标签: android android-layout android-asynctask android-ui android-progressbar