简体   繁体   English

Android弹出窗口未显示内容

[英]Android Pop-up Window not displaying contents

I am trying to have a pop up window display results in a table after selecting certain things. 我试图在选择某些内容后在表格中弹出窗口显示结果。 Below is my .xml of my popup window and the code I'm using to try to pull it up. 以下是弹出窗口的.xml和用于尝试将其拉起的代码。 The problem is that when it pops up, it is only displaying a black box, not the rest of the contents. 问题是,当它弹出时,它仅显示一个黑框,而不显示其余内容。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/outerwindow"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="80dp"
android:gravity="center"
android:background="#000000"
android:baselineAligned="true"
>

<TextView
    android:id="@+id/insert"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/rectangle"
    android:gravity="top"
    android:padding="7dp"
    android:text="@string/insert" />

<LinearLayout
    android:id="@+id/window"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:baselineAligned="true"
    android:orientation="horizontal"
    android:layout_marginTop="30dp"
    android:weightSum="10" >

    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_marginLeft="20dp"
        android:layout_weight="2" >

        <LinearLayout
            android:id="@+id/material"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:baselineAligned="false"
            android:orientation="vertical"
            android:weightSum="6" >

            <ImageButton
                android:id="@+id/close"
                android:layout_width="wrap_content"
                android:layout_height="33dp"
                android:layout_gravity="center"
                android:contentDescription="@string/back_arraw"
                android:scaleType="centerCrop"
                android:src="@android:drawable/ic_menu_revert" />

            <TableRow
                android:id="@+id/pRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#3b7fcc"
                android:baselineAligned="true" >

                <TextView
                    android:id="@+id/p0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/p"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>

            <TableRow
                android:id="@+id/mRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#ffff57"
                android:baselineAligned="false" >

                <TextView
                    android:id="@+id/m0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/m"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>

            <TableRow
                android:id="@+id/kRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#cc3333"
                android:baselineAligned="false" >

                <TextView
                    android:id="@+id/k0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/k"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>

            <TableRow
                android:id="@+id/nRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#356638"
                android:baselineAligned="false" >

                <TextView
                    android:id="@+id/n0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/n"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>

            <TableRow
                android:id="@+id/sRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#ff8936"
                android:baselineAligned="false" >

                <TextView
                    android:id="@+id/s0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/s"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>

            <TableRow
                android:id="@+id/hRow0"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#898989"
                android:baselineAligned="false" >

                <TextView
                    android:id="@+id/h0"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:gravity="center"
                    android:text="@string/h"
                    android:textColor="#b0b0b0"
                    android:textSize="27dp" />
            </TableRow>
        </LinearLayout>
    </FrameLayout>

    <TabHost
        android:id="@+id/tabhost"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_marginRight="20dp"
        android:layout_weight="8">

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:baselineAligned="false"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="33dp"
                android:layout_gravity="top" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:baselineAligned="false"
                    android:orientation="vertical"
                    android:weightSum="6" >

                    <TableRow
                        android:id="@+id/pRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#3b7fcc"
                        android:baselineAligned="true" >

                        <TextView
                            android:id="@+id/p3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/mRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ffff57"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/m3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/kRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#cc3333"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/k3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/nRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#356638"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/n3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/sRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ff8936"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/s3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/hRow3"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#898989"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/h3"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:baselineAligned="false"
                    android:orientation="vertical"
                    android:weightSum="6" >

                    <TableRow
                        android:id="@+id/pRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#3b7fcc"
                        android:baselineAligned="true" >

                        <TextView
                            android:id="@+id/p2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/space"
                        android:layout_width="fill_parent"
                        android:layout_height="1dp"
                        android:baselineAligned="true" />

                    <TableRow
                        android:id="@+id/mRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ffff57"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/m2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/kRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#cc3333"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/k2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/nRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#356638"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/n2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/sRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ff8936"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/s2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/hRow2"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#898989"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/h2"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:baselineAligned="false"
                    android:orientation="vertical"
                    android:weightSum="6" >

                    <TableRow
                        android:id="@+id/pRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#3b7fcc"
                        android:baselineAligned="true" >

                        <TextView
                            android:id="@+id/p1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/mRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ffff57"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/m1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/kRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#cc3333"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/k1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/nRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#356638"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/n1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/sRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#ff8936"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/s1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>

                    <TableRow
                        android:id="@+id/hRow1"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:layout_weight="1"
                        android:background="#898989"
                        android:baselineAligned="false" >

                        <TextView
                            android:id="@+id/h1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:gravity="center"
                            android:text=""
                            android:textColor="#000000"
                            android:textSize="17dp" />
                    </TableRow>
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</LinearLayout>
</LinearLayout>

code in my main: 我的主要代码:

inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    popView = inflater.inflate(R.layout.popup, (ViewGroup) findViewById(R.id.outerwindow));
    popup = new PopupWindow(popView,100,100, true);
    popup.setBackgroundDrawable(new BitmapDrawable());

later I use this command to bring it up 以后我用这个命令来启动它

popup.showAtLocation(findViewById(R.id.primary), Gravity.CENTER, 0, 0);

Obviously my main screen's ID is called primary, and when the the pop up comes up, its just a black square in the center of the screen (because I used black to see it actually pop up) and clicking outside of it makes it go away. 显然我的主屏幕的ID被称为主ID,当弹出窗口出现时,它只是屏幕中心的一个黑色正方形(因为我用黑色看到了它的实际弹出),并且在其外部单击使其消失了。 This is becoming a very annoying problem, any help would be appreciated. 这正在成为一个非常烦人的问题,我们将不胜感激。

Yeah... So as you can see above my window was only 100x100... That's why the content was blank... I was only showing the first 100x100 lol. 是的...您可以在窗口上方看到100x100 ...这就是内容空白的原因...我只显示了前100x100大声笑。 Sorry all for being dumb. 对不起,大家都傻了。 Took me a good few hours to realize this. 花了我几个小时才意识到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM