2012-11-10 4 views
3

Android에서는 로그인 할 때 제목과 메시지없이 사용자 정의 ProgressDialog 상자를 사용하고 싶습니다. 나는 그것을 작동시키는 데 어려움을 겪고있다. android에서 제목과 메시지를 제거하는 방법 ProgressDialog

enter image description here

가 어떻게 내 코드에서 이것을 적용 할 수 있습니다

나는 다음과 같은 GIF처럼 원하는 (아무 제목이나 메시지를 알 수 없음)?

내가 가진 코드 (작동하지 않습니다) :

<Progressbar 
android:id="@+id/progressBar2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:indeterminateDrawable="@drawable/progress_custom" 
android:indeterminateOnly="false" /> 

을이 제는 progress_custom.xml입니다 : 내가 로그인 할 때 즉,이해서 ProgressDialog가 표시되도록

<?xml version="1.0" encoding="utf-8"?> 
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:pivotX="50%" 
    android:pivotY="50%" > 

    <shape 
     android:innerRadiusRatio="4" 
     android:shape="ring" 
     android:thicknessRatio="5.333" 
     android:useLevel="false" > 

     <size 
      android:height="18dip" 
      android:width="18dip" /> 

     <gradient 
      android:centerColor="#886688cc" 
      android:centerY="0.50" 
      android:endColor="#ff6688cc" 
      android:startColor="#006688cc" 
      android:type="sweep" 
      android:useLevel="false" /> 
    </shape> 

</animated-rotate> 

나는 그것을 원한다. 사용 방법은 다음과 같습니다.

public class MainSerenaActivity extends Activity { 
    EditText uname; 
    EditText pass; 
    EditText server; 
    Button login; 
    String strUname; 
    String unamePass; 
    String strPass; 
    String strServer; 
    String strServer_fn; 
    String unamepass; 
    String uPass; 
    String encPass; 
    TextView reg_txt; 
    MyApplication app; 
    String passwde; 
    ProgressDialog pd; 
    CheckBox servercheck_btn; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     // getActionBar().setDisplayHomeAsUpEnabled(true); 

     uname = (EditText) findViewById(R.id.user_edt_lg); 
     pass = (EditText) findViewById(R.id.pass_edt_lg); 
     server = (EditText) findViewById(R.id.server); 
     login = (Button) findViewById(R.id.login); 
     servercheck_btn = (CheckBox) findViewById(R.id.checkBox1); 
     pd=(ProgressBar)findViewById(R.id.progressBar2); 
     login.setOnClickListener(new View.OnClickListener() { 

      @SuppressLint("ShowToast") 
      public void onClick(View v) { 
       strUname = uname.getText().toString().trim(); 
       strPass = pass.getText().toString().trim(); 

       MyApplication.setUserID(strUname); 
       MyApplication.setPassWord(strPass); 

       if (isInternetAvailable()) { 
        if ((uname.getText().toString()).equals("") 
          && (pass.getText().toString()).equals("")) { 

         Toast toast = Toast.makeText(MainSerenaActivity.this, 
           "please enter username & password ", 
           Toast.LENGTH_LONG); 
         toast.show(); 

        } else { 

         MyThread t = new MyThread(MainSerenaActivity.this, 0); 
         pd=ProgressDialog.show(MainSerenaActivity.this, "", ""); 


         t.start(); 
         Toast.makeText(MainSerenaActivity.this, 
           "Successfully login", Toast.LENGTH_SHORT) 
           .show(); 
         uname.setText(""); 
         pass.setText(""); 
         server.setText(""); 
         servercheck_btn.setChecked(false); 
        } 
       } 

       else { 
        Toast toast = Toast 
          .makeText(
            MainSerenaActivity.this, 
            "No internet available.Please turn on the internet", 
            Toast.LENGTH_LONG); 
        toast.show(); 

       } 

      } 

     }); 

    } 

    public boolean isInternetAvailable() { 
     ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); 
     NetworkInfo netInfo = cm.getActiveNetworkInfo(); 
     if (netInfo != null && netInfo.isConnectedOrConnecting()) { 
      return true; 
     } 
     return false; 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     getMenuInflater().inflate(R.menu.activity_main, menu); 
     return true; 
    } 

    class MyThread extends Thread { 
     Context con; 
     int but; 
     Intent in; 

     MyThread(Context con, int but) { 
      this.con = con; 
      this.but = but; 
     } 

     public void run() { 
      try { 
       switch (but) { 
       case 0: 
        in = new Intent(MainSerenaActivity.this, Second_Btn.class); 
        if (servercheck_btn.isChecked()) { 
         if ((server.getText().toString()).equals("")) { 
          Toast toast = Toast.makeText(
            MainSerenaActivity.this, 
            "please enter server ", Toast.LENGTH_SHORT); 
          toast.show(); 
         } else { 
          strServer = server.getText().toString().trim(); 
          strServer_fn = "https://" + strServer; 
          MyApplication.setServer(strServer_fn); 
         } 
        } else { 
         if ((server.getText().toString()).equals("")) { 
          strServer_fn = url; 
          MyApplication.setServer(strServer_fn); 
         } else { 
          strServer = server.getText().toString().trim(); 
          strServer_fn = url; 
          MyApplication.setServer(strServer_fn); 
         } 

        } 
        startActivity(in); 

        break; 

       } 
      } 

      catch (Exception e) { 
      } 

      pd.dismiss(); 

     } 
    } 

} 

그러나 제목과 메시지에는 여전히 GIF가 표시됩니다. 나는 회 전자 만 원해, 어떻게해야합니까?

답변

2

먼저 Activity Indocator 클래스를 만들고 아래와 같이 생성자를 만듭니다.

public ActivityIndicator(Context context) { 
    super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    setContentView(R.layout.activityindicator_dialog); 

    setCancelable(true); 

    RelativeLayout main = (RelativeLayout) findViewById(R.id.main); 
    main.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));  
} 

이제 진도 대화 상자를 설정하고 싶다면 아래 코드를 입력하십시오. 사용자 정의 된 진행 대화 상자가 표시됩니다. 작동 표시등의

private static ActivityIndicator activityIndicator; 
public static void hideActivityViewer() { 
    if (activityIndicator != null) { 
     activityIndicator.dismiss(); 
    } 
} 

public static void showActivityViewer(Context context) { 
    if (activityIndicator == null) { 
     activityIndicator = new ActivityIndicator(context); 
    } 
    activityIndicator.show(); 
} 

public static void clearDialogs() { 
    activityIndicator = null; 
} 

및 XML 내가 내 코드에 ActivityIndicator 클래스를 생성이 내이 자꾸 회신에 대한

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="fill_parent"> 
<RelativeLayout android:gravity="center" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:id="@+id/main" android:background="@drawable/overlay_bck"> 
    <TextView android:text="@string/loading" 
     android:textSize="15sp" android:textColor="#FFFFFF" android:id="@+id/text" 
     android:textStyle="bold" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:gravity="center_horizontal"></TextView> 
    <ProgressBar android:id="@+id/progress" android:layout_below="@+id/text" 
     style="@android:style/Widget.ProgressBar" android:layout_centerHorizontal="true" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" /> 
</RelativeLayout> 

+0

감사 arpit을 다음과 같이이다 – crickpatel0024

관련 문제