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
Java Android Emulator中未显示Imagebutton_Java_Android - Fatal编程技术网

Java Android Emulator中未显示Imagebutton

Java Android Emulator中未显示Imagebutton,java,android,Java,Android,我有一个问题,我找不到解决办法。我正在Android SDk上创建一个imagebutton,虽然它在预览窗口中显示,但在Nexus6 Emulator中并没有显示。图片附在这里 xml文件的代码是 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema

我有一个问题,我找不到解决办法。我正在Android SDk上创建一个imagebutton,虽然它在预览窗口中显示,但在Nexus6 Emulator中并没有显示。图片附在这里

xml文件的代码是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp"
    tools:context=".ViewActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textSize="@dimen/activity_bold_textsize"
    />


    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:src="@tools:sample/avatars" />

    <CheckBox
        android:id="@+id/checkBox"

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/rememberMe" />

    <RadioGroup
        android:id="@+id/radio_g1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <RadioButton
            android:id="@+id/rad1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/rad1"/>
        <RadioButton
            android:id="@+id/rad2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/rad2"
            />
    </RadioGroup>

    <ToggleButton
        android:id="@+id/toggleButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/togb1" />

    <Switch
        android:id="@+id/switch1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/Switch" />

</LinearLayout>

您不知道
工具
android
之间的区别。
tools:src=“@tools:sample/avatars”
仅在IDE预览时显示。 改为
android:src=“@tools:sample/avatars”


检查文档:

您不知道
工具
android
之间的区别。
tools:src=“@tools:sample/avatars”
仅在IDE预览时显示。 改为
android:src=“@tools:sample/avatars”


检查文档:

原因,您使用的是
工具:src
属性,而不是
android:src

工具:
=仅在预览仿真器中工作。它只是给你一个暂时的暗示

android:
=用于已定义的实际定义


例如,如果在textView中使用
工具:text
。它只显示为如何应用主题的提示。

原因是,您使用的是
工具:src
属性,而不是
android:src

工具:
=仅在预览仿真器中工作。它只是给你一个暂时的暗示

android:
=用于已定义的实际定义


例如,如果在textView中使用
工具:text
。它只显示为“how looks applied”主题的提示。

很抱歉,我刚刚阅读了文档并选择了您的答案作为最佳答案,但当我运行与您建议相同的代码时,它不起作用。相反,我得到的错误是`错误:链接文件资源失败。`。Plz帮助。@请添加日志目录。请检查此链接。它有完整的日志。抱歉@AmitRay,但是
android:src
not不能使用
@tools:sample/avatars
。请使用另一张drawble或彩色图像,而不是
@tools:sample/avatars
谢谢您的回复。我现在正在使用drawable文件夹制作图像,但我不明白为什么android无法访问相同的源代码。很抱歉,我刚刚阅读了文档并选择了您的答案作为最佳答案,但当我运行您建议的相同代码时,它不起作用。相反,我得到的错误是`错误:链接文件资源失败。`。Plz帮助。@请添加日志目录。请检查此链接。它有完整的日志。抱歉@AmitRay,但是
android:src
not不能使用
@tools:sample/avatars
。请使用另一张drawble或彩色图像,而不是
@tools:sample/avatars
谢谢您的回复。我现在正在使用drawable文件夹制作图像,但我不明白为什么android无法访问同一个源。