0

응용 프로그램을 개발 중입니다.Android : 비동기 작업에서 진행률 막대가 중지됩니다.

<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> 

을 지금은 같은 자바 코드의 흐름 데 :

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. 

이가이다를 다음과 같이 코드는

enter image description here

: 어떤에서 내 레이아웃과 같다 내 애플 리케이션의 고정 흐름.

문제점 : 내 액티비티가 제대로 실행되면 진행하지만 비동기 태스크 실행이 시작되면 진행률 표시 줄이 중지되어 이동합니다.

나는 같은 링크에서 솔루션을 시도 :

Link

을하지만 넣어 밖으로는 동일합니다.

또한 내가 그것을 여러분의 소중한 제안을 어떻게 나에게 제안 해주십시오 비동기 2 및 비동기 3

에 다시 비동기 일에있을 때 "실행 시간 텍스트보기 변경"의 텍스트를 변경하고 싶습니다. 필요하면 질문의 명확한 설명을 위해 회신 해주십시오. 당신의 XML로

+2

progressbar 코드를 표시 –

+0

@manojFedge 그냥 질문을, 왜 모든 작업 (모든 기능을 호출) 1 asyncTask를 사용하여 실행하지? – Yazan

+0

cat 로그에 오류가 있습니까? 링크를 따라 간다면 코드 흐름에서 일부 객체에 대한 잠금이있는 것처럼 보입니다. – User12111111

답변

0

, 당신의 ProgressBar의

android:indeterminate="true" 

를 추가합니다. 이것은 무한 애니메이션을 가능하게합니다.

이 정보가 도움이되기를 바랍니다.

+0

답장을 보내 주셔서 감사합니다. 내 문제는 귀하의 ans에 의해 부분적으로 해결됩니다. 그러나 활동을 마치기 전에 얼마 동안 진행 표시 줄이 멈 춥니 다. 그리고 비동기 2에서 텍스트를 변경하는 방법을 알려주십시오. –

+0

텍스트를 변경하려면 AsyncTask 내부에서 사용되는 onProgressUpdate 메소드를 사용할 수 있습니다. http://developer.android.com/reference/android/os/AsyncTask.html을 확인하십시오. onProgressUpdate 메서드를 살펴보면 AsyncTask에서 UI 스레드를 업데이트 할 수 있습니다. – AmaJayJB

관련 문제