0

Android 앱을 개발 중이며 알아볼 수없는 사소한 문제가 발생했습니다. 사용자가 검색 버튼을 클릭 한 후 진행률 서클을 표시하려고합니다. 하지만 지금까지 작성한 코드로 진행 막대를 만들 수없는 방법이 있습니다.android progress circle이 표시되지 않습니다.

코드 .. 다음과 같습니다

내 조각 클래스에서

아래 검색 버튼을 클릭에 대한 코드는 ...

//create a progress dialog circle. 
      spinner = (ProgressBar) searchByDoctor.findViewById(R.id.progressBar1); 
      spinner.setVisibility(View.VISIBLE); 
      spinner.setIndeterminate(true); 
      List<DocInfoTO> docList = doctorService.findDocBySearchCriteria(docSearchInputTO); 
      if(docList != null && docList.size() > 0) 
      { 
       //stop the progress cirlce as soon as we get the results. 
       spinner.setVisibility(View.GONE); 
       spinner.setIndeterminate(false); 
       List<SearchResultDoctorRowItem> rowItems = new ArrayList<SearchResultDoctorRowItem>(); 
       for(DocInfoTO doc : docList) 
       { 
        rowItems.add(YourDocUtil.setDoctorRowItemDto(doc)); 
       } 

XML은이처럼

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/android"> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/enter_doc_name" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:layout_gravity="center_horizontal" 
    android:paddingTop="200dp"/> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="238dp" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal|center_vertical" 
    android:layout_marginTop="20dp" 
    android:ems="10" 
    android:inputType="textPersonName" 
    android:hint="@string/doctor_Name" /> 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" > 

    <LinearLayout 
     android:id="@+id/footerSearch" 
     style="?metaButtonBarStyle" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|center_horizontal" 
     android:background="@color/black_overlay" 
     android:orientation="horizontal" 
     > 

     <Button 
      android:id="@+id/button1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/searchDoc" 
      /> 
    </LinearLayout> 

    <ProgressBar 
     android:id="@+id/progressBar1" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal|center_vertical"/> 

</FrameLayout> 

답변

0

코드는 괜찮습니다. spinner.setVisibility(View.VISIBLE) 상태에서 spinner.setVisibility(View.GONE)으로 너무 빨리 진행되고 있기 때문에 진행률 표시 줄을 볼 수없는 이유입니다. 간단히 말해 진행 표시 줄이 너무 빨리 나타나서 사라지는 것입니다.

이 코드 doctorService.findDocBySearchCriteria(docSearchInputTO)을 실행하는 데 오래 걸리면 진행률 막대를 볼 수 있습니다. '

+0

findDocBySearchCriteria 메서드를 호출하면 서버가 손상 될 수 있으므로 실제로는 조금 길어집니다. 나는 적어도 spinner 회전을 볼 수 있도록 확인을 위해서 Thread.sleep (7000)을 추가하려고 시도했다. 그러나 나는 나를 도왔다. – Jack

+0

하나의 빌드에 대해 spinner.setVisibility (View.GONE) 주석 처리를 시도해보십시오. – DrkStr

+0

그 이유는'doctorService.findDocBySearchCriteria (docSearchInputTO); '를 호출하고 같은 스레드에서 스피너를 호출했기 때문입니까? – Jack

0

작성한 코드의 어느 곳에서나 spinner.setVisibility(View.GONE) 또는 spinner.setVisibility(View.Invisible)을 호출하지 않았는지 확인하십시오. 스피너가 나타나지 않게됩니다.