模拟器中没有控件?

时间:2012-12-07 20:57:39

标签: android

我正在尝试使用eclipse ADT运行一个非常简单的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:layout_height="match_parent"
    android:orientation="horizontal">
    <EditText android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send" 
        android:onClick="sendMessage"/>
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

您需要致电setContentView (R.layout.yourLayout);此方法会使您的布局文件膨胀,并允许它显示在您的活动中。