2012-07-08 319 views
0

我一直在閱讀Google's android tutorial,我遇到了一個問題...
在教程中,他們解釋了XML元素(EditText和Button),最後他們說如何調試程序看到按鈕+文本字段。
的問題是,該仿真器不顯示他們..只是一個黑色的屏幕。
我甚至嘗試添加這行來的onCreate功能 -模擬器沒有顯示XML內容

System.out.println("Hello World!"); 

但仍仿真器只顯示黑屏.. 這裏是主要的.java文件 - http://pastebin.com/G5J9YjNe

和XML文件(我提到什麼代碼是什麼文件) - http://pastebin.com/VnRwAfMW

我該怎麼辦?

感謝很多爲大家誰可以幫助!

回答

0
System.out.println("Hello World!"); 

不打印屏幕上的任何東西。它可以在Consol上看到。我嘗試了下面的代碼,併爲我工作得很好。

//主要活動 公共類MainActivity擴展活動{

@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.kuchbhi); 
     System.out.println("Hello World!"); 
    } 

佈局/.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:orientation="horizontal" > 

    <EditText android:id="@+id/text_message" 
    android:layout_weight="1" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:hint="enter text" /> 

    <Button android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="Send" /> 

    </LinearLayout> 

清單文件..

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.test" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="8" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <activity 
      android:name="MainActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 


    </application> 

</manifest> 

試試這個代碼,讓我知道你所看到的。

我想你的源代碼,這是對我工作的罰款。見屏幕

your app screen