Reputation: 10191
I'm working through the MyFirstApp tutorial on http://developer.android.com using the latest SDKs.
I've created a 4.1 app and set up my emulator with LCD density of 213, a VM application heap of 48 and a device RAM size of 512. The resolution is 720x1280.
When I first got this I had "Android" flash up on the emulator.
I noticed that my layout main.xml had not been created by default so I added it myself in res/layouts
I added the following main.xml and 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>
Now when I run my emulator I just get a black screen. My guess is that either I've not added main.xml correctly or there's something wrong in my xml file.
Upvotes: 1
Views: 155
Reputation: 27748
Map your XML file (main.xml) to your Activity by using the following statemetn in your Activity's onCreate()
method:
setContentView(R.layout.main);
Upvotes: 2