0

我正在关注本教程,最后我有以下代码,但是当我运行应用程序时,我没有得到按钮或文本字段,只是你好世界。

http://developer.android.com/training/basics/firstapp/building-ui.html

问题是什么

布局xml

  <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:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:orientation="horizontal" 



     tools:context=".MainActivity" >
    <EditText android:id="@+id/edit_message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" />
    <Button
     android:aalyout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="text"="@string/buton_send"/>

字符串值

         <?xml version="1.0" encoding="utf-8"?>
        <resources>

         <string name="app_name">My First App</string>
        <string name="action_settings">Settings</string>
        <string name="edit_message">Enter a message</string>
        <string name="button_send">Send</string>

4

2 回答 2

0

更改android:text="text"="@string/buton_send"/>android:text="@string/buton_send"/>

于 2013-04-11T10:13:41.413 回答
0

我们的布局应该如下

<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:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:orientation="horizontal" 
  tools:context=".MainActivity" >

<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />

<Button android:id="@+id/button1"   //here you missed the id....in your code
 android:aalyout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/buton_send"/>   //your code has incorrect syntax here

于 2013-04-11T10:19:18.723 回答