How to make a simple Android popup
This is a more complete example. This is an additional answer, which concerns the title of the question and not necessarily the specific details of the problem of OP. It will look as follows.

Make a popup layout
Add a layout file to res/layout that defines what the popup will look like.
popup_window.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#62def8"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_margin="30dp" android:textSize="22sp" android:text="This is a popup window."/> </RelativeLayout>
Click and show popup
Here is the code for the main activity of our example. Whenever a button is pressed, a pop-up window is inflated and displayed above the activity. Touching anywhere on the screen rejects the popup.
MainActivity.java
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void onButtonShowPopupWindowClick(View view) {
For reference, the main layout is also located here.
activity_main.xml
<?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_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.popupwindow.MainActivity"> <Button android:text="Show popup window" android:onClick="onButtonShowPopupWindowClick" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10dp"/> </LinearLayout>
Further study
It also helped to learn how to create a popup:
Suragch Jul 13 '17 at 10:14 2017-07-13 10:14
source share