Question

To create a simple working PopupWindow, we need to do the following:

popup_example.xml:

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:padding="10dip"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView         
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:text="Test Pop-Up" />

    </LinearLayout>

Java code

LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup_example, null, false),100,100, true);

pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);

My requirement is that I need a

<TEXTVIEW android:layout_height="wrap_content" android:layout_width="fill_parent" />

and a

<BUTTON android:id="@+id/end_data_send_button" android:text="Cancel"/>

in my popup_example.xml. How can I handle these two components in my Java code?

screenshot

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top