1

最新のSDKを使用して、http: //developer.android.comでMyFirstAppチュートリアルを実行しています。

4.1アプリを作成し、LCD密度が213、VMアプリケーションヒープが48、デバイスのRAMサイズが512のエミュレーターをセットアップしました。解像度は720x1280です。

これを最初に入手したとき、エミュレーターで「Android」がフラッシュアップしていました。

レイアウトmain.xmlがデフォルトで作成されていないことに気付いたので、自分でres/layoutsに追加しました

次のmain.xmlとstrings.xmlを追加しました

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
    <EditText android:id="@+id/edit_message"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:hint="@string/edit_message" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send" />
</LinearLayout>



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

エミュレータを実行すると、黒い画面が表示されます。私の推測では、main.xmlを正しく追加していないか、xmlファイルに何か問題があります。

4

1 に答える 1

2

onCreate()アクティビティのメソッドで次のstatemetnを使用して、XMLファイル(main.xml)をアクティビティにマップします。

setContentView(R.layout.main);
于 2012-07-14T12:16:40.797 に答える