2014-09-28 67 views
0

我正在做一個簡單的android應用程序,但它不想出現,我真的不明白爲什麼。這是我的代碼:按鈕不顯示在Android應用程序

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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" 
    tools:context="com.example.pressme_alpha.MainActivity" > 

    <TextView 
     android:id="@+id/score" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginStart="5dp" 
     android:text="" 
     android:textSize="20sp" /> 

    <TextView 
     android:id="@+id/money" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginEnd="5dp" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:text="" 
     android:textSize="20sp" /> 

    <Button 
     android:id="@+id/button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="@string/press_me" 
     android:textSize="30sp" 
     android:onClick="handleButtonClick" /> 

</RelativeLayout> 

當我打開應用程序,文字作品,顯示了,但按鈕只是不會出現。

+0

你的活動的Java代碼在哪裏? – 2014-09-28 20:29:00

+0

嘗試做一個_Project - >清理... _如果你使用的是Eclipse。 – Voicu 2014-09-28 20:37:56

+0

重新啓動您的eclipse或清理您的項目。我看不出那個代碼有什麼問題。 – CENT1PEDE 2014-09-28 21:13:45

回答

0

我試着運行這段代碼,按鈕確實顯示出來。 然而,沒有額外的文本,因爲TextView分數和金錢都將文本設置爲空白 - ==> android:text =「」 該按鈕與文本「Press me」一起顯示。

相關問題