我已经复制并粘贴来自本网站上的Form stuff示例的代码。当我尝试运行该项目时出现错误,该项目有一个带有白色十字的小红色正方形,但是当向下钻入项目元素(使用eclipse)时,会出现错误元素。在eclipse的问题标签中,我有以下文本试图运行android教程时未定义的错误表格的东西
说明资源路径位置类型 未解析的aapt错误(s)!检查控制台的输出。 HelloFormStuff2未知Android包装问题
但是在控制台中没有任何东西! 下面是代码和元素,我使用...
HelloFormStuff2.java
package com.android.HelloLinearLayouts;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HelloFormStuff2 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks
Toast.makeText(HelloFormStuff2.this,
"Beep Bop",
Toast.LENGTH_SHORT).show();
}
});
}
}
**res/drawable-hdpi/android-button.xml**
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/android_pressed"
android:state_pressed="true"/>
<item android:drawable="@drawable/android_focused"
android:state_focused="true"/>
<item android:drawable="@drawable/android_normal"/>
</selector>
**res/layout/main.xml**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@drawable/android_button" />
</LinearLayout>
工作正常!我干净了,不知道问题是什么,但它现在正在运行! :)谢谢你的帮助阿米戈! – Stephen 2010-09-05 10:27:13
他应该接受你的答案! – 2011-01-12 18:10:12