0

我一直在阅读Google 的 android 教程,但遇到了一个问题……
在教程中,他们解释了 XML 元素(EditText 和 Button),最后他们说如何调整程序以查看按钮 + 文本字段。
问题是,模拟器没有显示它们..只是一个黑屏。
我什至尝试将此行添加到 onCreate 函数 -

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

但模拟器仍然只显示黑屏。这是.java主文件 - http://pastebin.com/G5J9YjNe

以及 XML 文件(我提到了什么代码是什么文件) - http://pastebin.com/VnRwAfMW

我该怎么办?

非常感谢所有愿意提供帮助的人!

4

1 回答 1

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

不会在屏幕上打印任何东西。它可以在Consol上看到。我尝试了下面的代码并且对我来说工作正常。

// 主活动 public class MainActivity extends Activity {

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

试试这段代码,让我知道你看到了什么。

我试过你的源代码,它对我来说很好。看屏幕

你的应用屏幕

于 2012-07-08T09:14:04.840 回答