How to custom dialog Android example

How to custom dialog Android example - Hello friend inabnomaniiyaha, In the article that you read this time with the title How to custom dialog Android example, we have prepared this article well for you to read and take information in it. hopefully the contents of the post Artikel android-example,what we write you can understand. Alright, happy reading.

Judul : How to custom dialog Android example
link : How to custom dialog Android example

Baca juga


How to custom dialog Android example

In Android programming you want to custom dialog for your interface to be beautiful, but you don't know how, today I will introduce you a pretty simple custom dialog in Android with the following steps:

How to custom dialog Android example

Step1 : create layout_dialog.xml

<?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:layout_alignParentLeft="true"

            android:layout_alignParentStart="true"

            android:layout_alignParentTop="true"

            android:background="@android:color/transparent"

            android:orientation="vertical">


            <FrameLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content">


                    <EditText

                        android:ems="10"

                        android:layout_width="match_parent"

                        android:layout_height="wrap_content"

                        android:background="@android:color/white"

                        android:inputType="textMultiLine"

                        android:layout_marginTop="20dp"

                        android:lines="8"

                        android:maxLines="10"

                        android:minLines="6"

                        android:scrollbars="vertical" />


                <ImageView

                    android:layout_marginTop="0dp"

                    android:layout_width="wrap_content"

                    android:layout_height="50dp"

                    android:layout_gravity="center|top"

                    android:src="@drawable/ic_launcher" />

            </FrameLayout>



            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:layout_margin="10dp"

                android:background="@android:color/white"

                android:weightSum="2">


                <Button

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:background="@android:color/black"

                    android:text="Submit"

                    android:textColor="#FFFFFF" />


                <View

                    android:layout_width="4dp"

                    android:layout_height="match_parent"

                    android:background="@android:color/transparent" />


                <Button

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_weight="1"

                    android:background="@android:color/black"

                    android:text="Cancel"

                    android:textColor="#FFFFFF" />


            </LinearLayout>

        </LinearLayout>

Step 2: Create class activity custom dialog

public class CustomDialogClass extends Dialog implements

android.view.View.OnClickListener {

 public Activity c;

  public Dialog d;

  public Button yes, no;


  public CustomDialogClass(Activity a) {

    super(a);

    // TODO Auto-generated constructor stub

    this.c = a;

  }


  @Override

  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.custom_dialog);

    yes = (Button) findViewById(R.id.btn_yes);

    no = (Button) findViewById(R.id.btn_no);

    yes.setOnClickListener(this);

    no.setOnClickListener(this);


  }


  @Override

  public void onClick(View v) {

    switch (v.getId()) {

    case R.id.btn_yes:

      c.finish();

      break;

    case R.id.btn_no:

      dismiss();

      break;

    default:

      break;

    }

    dismiss();

  }



That's the articleHow to custom dialog Android example

That's it for the article How to custom dialog Android example this time, hopefully can be useful for all of you. well, see you in another article post.

You are now reading the articleHow to custom dialog Android example with link addresshttps://inabnonapudyawanabing.blogspot.com/2021/02/how-to-custom-dialog-android-example.html

Related Posts :

0 Response to "How to custom dialog Android example"

Post a Comment

Tips Tricks for Android Phone

Tips & Tricks for Android Phone is a free android app and Collection of Tips and Tricks related to using your android mobile device lik...