Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Android Dialog

AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage("Write your message here.");
builder1.setCancelable(true);

builder1.setPositiveButton(
    "Yes",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

builder1.setNegativeButton(
    "No",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

AlertDialog alert11 = builder1.create();
alert11.show();
Comment

android dialog box example

runOnUiThread(new Runnable() {
    @Override
    public void run() {

        if (!isFinishing()){
            new AlertDialog.Builder(YourActivity.this)
              .setTitle("Your Alert")
              .setMessage("Your Message")
              .setCancelable(false)
              .setPositiveButton("ok", new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      // Whatever...
                  }
              }).show();
        }
    }
});
Comment

android dialog modal

public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
	setCancelable(false);
}
Comment

custom dialog in android

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:layout_gravity="center"
    android:layout_marginLeft="55dp"
    android:layout_marginRight="55dp"
    android:gravity="center">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="165dp"
            android:layout_gravity="center"
            android:layout_marginEnd="60dp"
            android:layout_marginStart="60dp"
            app:cardCornerRadius="8dp"
            app:cardElevation="15dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="14dp"
                android:gravity="center"
                android:text="Quit Earning?"
                android:textColor="@android:color/black"
                android:textSize="20dp"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginEnd="20dp"
                android:layout_marginStart="20dp"
                android:gravity="center"
                android:text="You are 400pts. away from 
 unlocking rewards. quit Earning?"
                android:textSize="18dp"
                android:textStyle="bold" />

        </android.support.v7.widget.CardView>
    </LinearLayout>

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:id="@+id/frmNo"
        android:layout_marginRight="45dp"
        android:layout_marginTop="75dp">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:src="@android:color/transparent"
            app:backgroundTint="@color/fab2" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:elevation="6dp"
            android:text="No"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/white"
            android:textStyle="bold" />
    </FrameLayout>

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:id="@+id/frmOk"
        android:layout_marginLeft="50dp"
        android:layout_marginTop="75dp">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:src="@android:color/transparent"
            app:backgroundTint="@color/fab1" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:elevation="6dp"
            android:text="Ok"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@android:color/white"
            android:textStyle="bold" />
    </FrameLayout>
</FrameLayout>
Comment

PREVIOUS NEXT
Code Example
Java :: maven artifact 
Java :: Java program to print decimal to octal conversion 
Java :: unable to access jarfile 
Java :: java bufferedreader read all lines 
Java :: how to change color of drawable in android 
Java :: palindrome java 
Java :: get last string separated by / 
Java :: apache csv get headers 
Java :: spring boot param object 
Java :: how to get internet speed in android programmatically 
Java :: first and last digit of a number in java 
Java :: java enum 
Java :: uses or overrides a deprecated API. 
Java :: do...while loop Java 
Java :: java base64 to file 
Java :: convert list of dto to map java 
Java :: multiple condition inside for loop java 
Java :: swing getsource 
Java :: java.lang.NullPointerException 
Java :: hibernate in spring boot 
Java :: node in java 
Java :: jpa page sort 
Java :: adjust font scale in android studio 
Java :: java not equal to 
Java :: spring valid request body custom message 
Java :: Spigot coding how to send a message to player after commadn 
Java :: java spring username encode and decode 
Java :: queue and stack reader 
Java :: better way to check string on null and empty java 
Java :: android studio clock bar change color programmatically 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =