İçeriğe geç

Android ProgressDialog ve Custom Dialog

Kullanıcıları devam eden işlemler hakkında bilgilendirmek için kullanabileceğiniz Dialog örnekleri.

Keys;

  • ProgressDialog
  • ProgressDialog setProgressStyle
  • ProgressDialog setMessage
  • ProgressDialog setIndeterminate
  • ProgressDialog setCancelable
  • ProgressDialog setContentView
  • ProgressDialog setTitle
  • ProgressDialog show
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="50dp">
	<TextView
android:text="Custom Dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textAlignment="center" />
	<TextView
android:text="This is custom dialog..."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:textAlignment="center" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.dialog.MainActivity"
android:orientation="vertical">
	<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/buttonProgress"
android:text="Progress Dialog" />
	<Button
android:text="CUSTOM DIALOG"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/buttonCustom" />
</LinearLayout>
public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // STYLE_SPINNER
    progressDialog.setMessage("Just wait...");
    progressDialog.setIndeterminate(false);
    progressDialog.setCancelable(true);

    // Progress Dialog
    Button buttonProgress = (Button) findViewById(R.id.buttonProgress);
    buttonProgress.setOnClickListener(new View.OnClickListener() {@Override
      public void onClick(View view) {
        progressDialog.show();
        progressDialog.setProgress(50);
      }
    });

    //Custom Dialog
    Button buttonCustom = (Button) findViewById(R.id.buttonCustom);
    buttonCustom.setOnClickListener(new View.OnClickListener() {@Override
      public void onClick(View view) {
        Dialog dialogCustom = new Dialog(MainActivity.this);
        dialogCustom.setContentView(R.layout.dialog);
        dialogCustom.setTitle("This is important");
        dialogCustom.show();
      }
    });
  }
}
Tarih:Android

İlk Yorumu Siz Yapın

Bir Cevap Yazın