2013-03-02 64 views
0

我剛開始讀入Android開發,所以我願意打賭有一個很簡單的解決這個..XML UI不會在Android正確顯示 - 按鈕和文本輸入不顯示

我也跟着上的導向Android開發人員網站,構建示例UI。圖形佈局顯示按鈕和文本輸入框沒有問題,所以它似乎沒有代碼的問題。出於某種原因,它不會顯示在AVT上,或者當我在手機上安裝APK時...我正在使用Galaxy Nexus並將AVT設置爲Galaxy Nexus。

我已經更新了ADT,並嘗試了幾件事情,但我假設有一些我可能已經忘記配置?有人可以幫忙嗎?

林新本,所以要很好;)

這裏是XML代碼:

<?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> 

在此先感謝

回答

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:orientation="horizontal"> 

<EditText android:id="@+id/edit_message"  
    android:layout_width="wrap_content" 
    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> 

也請檢查您是否已經調用的setContentView功能你的活動傳遞這個XML佈局

+0

是的,它是setcontentview不傳遞XML佈局。謝謝你的幫助! – Daveloper87 2013-03-04 00:25:05