【发布时间】:2012-01-08 00:14:52
【问题描述】:
我是 Android 编程新手,我正在学习来自 http://developer.android.com/resources/tutorials/views/index.html 的布局教程。完全是相对布局教程。我做了他们所说的一切,但是当我尝试在 android 模拟器中启动应用程序时,没有按钮、文本字段等。只有应用程序的名称显示在顶部。怎么了?这是模拟器的问题吗?我正在使用 Eclipse 版本:3.7.1。
编辑:
package pchot.tutorial;
import android.app.Activity;
import android.os.Bundle;
public class Tutorial1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pchot.tutorial"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Tutorial1Activity"
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>
布局是从http://developer.android.com/resources/tutorials/views/hello-relativelayout.html复制/粘贴
编辑:
好的,问题解决了。我需要删除“Hello World,Tutorial1Activity!”来自在 Eclipse 中创建项目时自动创建的 string.xml 文件。
【问题讨论】:
-
您知道 Logcat lampcms.blogspot.com/2010/07/… 或 DDMS developer.android.com/guide/developing/debugging/index.html 吗?我们很可能需要来自那里的信息。
-
也许您可以向我们展示您的代码,以便我们让您知道您错在哪里?
-
你打电话给
setContentView(...)我猜? -
如果您发布它会帮助我们回答。
-
@TryTryAgain:我的 LogCat 日志显示了一些奇怪的东西。首先有错误:“E/AndroidRuntime(197): ERROR: thread attach failed”但在此之前,VM 似乎是如何杀死我的活动的过程:D/ActivityManager(60): Uninstalling process pchot.tutorial。可悲的是,现在我对 Android 中的任何调试都不熟悉,我才刚刚开始。
标签: android android-layout android-emulator