2014-05-13 3 views
0

많은 응용 프로그램에서 이것을 보았지만 응용 프로그램에서 아무 것도 할 수 없기 때문에 ProgressDialog을 사용하지 않습니다. 그럴 필요가 없습니다. ProgressDialog 대신 다른 앱에서 보았을 때, ui가 진행 표시 줄을 보여줄뿐만 아니라 다른 작업도 할 수 있습니다. 예를 들어 전체 UI가 진행률 막대가되고 완료되면 주 UI가로드됩니다. 진행 상황이 활성화 될 때 다른 레이아웃을 사용한다고 생각합니다. 완료되면 주 레이아웃을 다시 가져옵니다. Android - 다른 레이아웃을 진행 막대로 사용하는 방법

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 
<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" > 
    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="79dp" 
     android:src="@drawable/load_more" /> 
    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/loading" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 
</LinearLayout> 

내가 그걸 어떻게 할 수 있을까요 I

: 이 같은 레이아웃을 만들어?

감사합니다.

답변

3

이 방법에는 여러 가지가 있습니다. 너를 편도로 봤어.

Custom Dialog을 만들고이 레이아웃을 Inflater으로로드하고 레이아웃을 Dialog으로 설정할 수 있습니다. 같은

LayoutInflater factory = LayoutInflater.from(Activity.this); 
View DialogView = factory.inflate(R.layout.custom_progress_layout, null); 

Dialog main_dialog = new Dialog(Activity.this,R.style.Theme_Dialog); 
main_dialog.setContentView(DialogView); 

progressBar=(ProgressBar)DialogView.findViewById(R.id.progressBar1); 
main_dialog.setCancelable(false); 
main_dialog.setCanceledOnTouchOutside(false); 
progressBar.setProgress(0); 
progressBar.setMax(100); 
main_dialog.show(); 

및 진행은 dismiss에게 당신이 어떤 TextView를 사용하여 진행 텍스트와 진행 상황을 표시 할 수있는 레이아웃도 main_dialog.dismiss();

를 사용하여이 대화 상자를 완료 할 때.

출력 : 답장을 보내

enter image description here

+0

덕분에, 나는 당신이 말을했다,하지만 여전히 대화입니다. 대화 상자를 열지 만 대화 상자가되기를 원하지 않습니다. 나는 progressbar를 얻고 싶습니다. 그리고 사라졌습니다. – user3579994

+1

@ user3579994 나는 당신에게 말했다. 다양한 방법이 있습니다. 이 [https://github.com/johnkil/Android-ProgressFragment](https://github.com/johnkil/Android-ProgressFragment)를 시도하거나이 'Layout'을 별도의 'Activity'로로드 할 수 있습니다. –