1runOnUiThread(new Runnable() {
2 @Override
3 public void run() {
4
5 if (!isFinishing()){
6 new AlertDialog.Builder(YourActivity.this)
7 .setTitle("Your Alert")
8 .setMessage("Your Message")
9 .setCancelable(false)
10 .setPositiveButton("ok", new OnClickListener() {
11 @Override
12 public void onClick(DialogInterface dialog, int which) {
13 // Whatever...
14 }
15 }).show();
16 }
17 }
18});
1<?xml version="1.0" encoding="utf-8"?>
2<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent"
6 android:layout_height="250dp"
7 android:layout_gravity="center"
8 android:layout_marginLeft="55dp"
9 android:layout_marginRight="55dp"
10 android:gravity="center">
11
12 <LinearLayout
13 android:layout_width="match_parent"
14 android:layout_height="match_parent"
15 android:layout_gravity="center_vertical"
16 android:gravity="center_vertical"
17 android:orientation="vertical">
18
19 <android.support.v7.widget.CardView
20 android:layout_width="match_parent"
21 android:layout_height="165dp"
22 android:layout_gravity="center"
23 android:layout_marginEnd="60dp"
24 android:layout_marginStart="60dp"
25 app:cardCornerRadius="8dp"
26 app:cardElevation="15dp">
27
28 <TextView
29 android:layout_width="wrap_content"
30 android:layout_height="wrap_content"
31 android:layout_gravity="center_horizontal"
32 android:layout_marginTop="14dp"
33 android:gravity="center"
34 android:text="Quit Earning?"
35 android:textColor="@android:color/black"
36 android:textSize="20dp"
37 android:textStyle="bold" />
38
39 <TextView
40 android:layout_width="wrap_content"
41 android:layout_height="wrap_content"
42 android:layout_gravity="center"
43 android:layout_marginEnd="20dp"
44 android:layout_marginStart="20dp"
45 android:gravity="center"
46 android:text="You are 400pts. away from \n unlocking rewards. quit Earning?"
47 android:textSize="18dp"
48 android:textStyle="bold" />
49
50 </android.support.v7.widget.CardView>
51 </LinearLayout>
52
53 <FrameLayout
54 android:layout_width="wrap_content"
55 android:layout_height="wrap_content"
56 android:layout_gravity="center"
57 android:id="@+id/frmNo"
58 android:layout_marginRight="45dp"
59 android:layout_marginTop="75dp">
60
61 <android.support.design.widget.FloatingActionButton
62 android:layout_width="60dp"
63 android:layout_height="60dp"
64 android:src="@android:color/transparent"
65 app:backgroundTint="@color/fab2" />
66
67 <TextView
68 android:layout_width="wrap_content"
69 android:layout_height="wrap_content"
70 android:layout_gravity="center"
71 android:elevation="6dp"
72 android:text="No"
73 android:textAppearance="?android:attr/textAppearanceMedium"
74 android:textColor="@android:color/white"
75 android:textStyle="bold" />
76 </FrameLayout>
77
78 <FrameLayout
79 android:layout_width="wrap_content"
80 android:layout_height="wrap_content"
81 android:layout_gravity="center"
82 android:id="@+id/frmOk"
83 android:layout_marginLeft="50dp"
84 android:layout_marginTop="75dp">
85
86 <android.support.design.widget.FloatingActionButton
87 android:layout_width="60dp"
88 android:layout_height="60dp"
89 android:src="@android:color/transparent"
90 app:backgroundTint="@color/fab1" />
91
92 <TextView
93 android:layout_width="wrap_content"
94 android:layout_height="wrap_content"
95 android:layout_gravity="center"
96 android:elevation="6dp"
97 android:text="Ok"
98 android:textAppearance="?android:attr/textAppearanceMedium"
99 android:textColor="@android:color/white"
100 android:textStyle="bold" />
101 </FrameLayout>
102</FrameLayout>