Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
弹出文本视图编辑器(格式化)Android_Android_Popup_Background Color - Fatal编程技术网

弹出文本视图编辑器(格式化)Android

弹出文本视图编辑器(格式化)Android,android,popup,background-color,Android,Popup,Background Color,我想在android中创建文本编辑器,并将其设置为主活动 下面是我的截图 <?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:layout_width="match_parent"

我想在android中创建文本编辑器,并将其设置为主活动 下面是我的截图

<?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:layout_width="match_parent"
    android:id="@+id/popup"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/background"
    android:alpha="0.92">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Format your Text Style Here"
        android:padding="10dp"
        android:textAlignment="center"
        android:textAppearance="?android:attr/textAppearanceLarge" />


    <TextView
        android:id="@+id/popupMainText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:layout_weight="0.03"
        android:background="#fff"
        android:gravity="center"
        android:text="This is a simple popup"
        android:textSize="25sp" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:gravity="center"
        android:text="Font Size"
        android:textSize="20sp" />

        <GridLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.14"
        android:columnCount="4"
        android:rowCount="5">


        <Button
            android:id="@+id/font1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_row="0"
            android:text="Font 1" />

        <Button
            android:id="@+id/font2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="1"
            android:layout_row="0"
            android:text="Font 2" />

        <Button
            android:id ="@+id/colorRed"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="@drawable/button_red_round"
            android:layout_column="0"
            android:layout_row="2"
            android:layout_margin="5dp"
            android:padding="15dp"
            />

    </GridLayout>


    <Button
        android:id="@+id/close"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10dp"
        android:text="Close" />

</LinearLayout>
我想要按钮点击事件设置预览和主要活动的颜色
但我的应用程序在事件应用于主活动后无法打开

是否有任何错误日志?问题是什么?java.lang.RuntimeException:无法启动活动ComponentInfo{com.package.name/com.package.name.SingleViewActivity}:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void android.view.view.setOnClickListener(android.view.view$OnClickListener)'这不容易读取。我建议编辑你的原始帖子以显示错误日志谢谢你的建议,因为我是android新手,你能建议我一些关于弹出窗口中文本格式的参考吗。在这种情况下,它会帮助我。你能发布导致错误的java代码吗?我想我更明白你现在想做什么
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/red_id">
        <shape android:shape="oval">
            <stroke android:color="#ffffff" android:width="5dp" />
            <solid android:color="#ff0000"/>
            <size android:width="30dp" android:height="30dp"/>
        </shape>
    </item>
</selector>
colorRed.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {   popupMainText.setBackground(colorRed.getResources().getDrawable(R.drawable.button_red_round));
            }
    });