0

My popup Window remains without background. I want a white popup saying whom won the game.

Java:

    LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);   
    PopupWindow pw = new PopupWindow(layoutInflater.inflate(R.layout.winner_popup,null, false), LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
    pw.showAtLocation(findViewById(R.id.main_layout), Gravity.CENTER, 0, 0);
    TextView winnerText = (TextView) pw.getContentView().findViewById(R.id.winnerTextView);
    winnerText.setText("Player 1 is the winner"); //Update the TextView 

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:orientation="vertical"
    android:background="@color/white">

    <TextView
        android:id="@+id/winnerTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/winnerTextViewString"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/winnerButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/winnerButtonString" 
        android:layout_marginLeft="45dp"/>

</LinearLayout>

Is it possible or should I use the alert-window instead?

Br

Jedi Schmedi
  • 746
  • 10
  • 36

0 Answers0