我开始了一个小型的android应用程序来学习。我在屏幕上放置了一个输入文本和按钮。这在模拟器上显示。之后,我按下按钮(它有一个onClickListener)申请裂缝,并告诉我模拟器的屏幕上显示:“......再次停止unexpectably.Try的应用”和我有一个“强制关闭”,这当然关闭的应用程序。 我清理并重建了很多次这个项目。我已经表明没有错误(使用eclipse) 这是布局/ main.xml中: Android应用程序失败并在点击按钮后停止
<ScrollView android:id="@+id/widget37" android:layout_width="247px"
android:layout_height="282px" android:scrollbars="vertical"
android:layout_x="38px" android:layout_y="130px">
</ScrollView>
<RadioButton android:id="@+id/compactList"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Compact List" android:layout_x="36px" android:layout_y="78px">
</RadioButton>
<RadioButton android:id="@+id/detailedList"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Detailed List" android:layout_x="176px"
android:layout_y="78px">
</RadioButton>
这是活动类:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class ShowStuffs extends Activity implements View.OnClickListener {
private Button searchbtn;
private EditText input;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
searchbtn = (Button)findViewById(R.id.searchBtn);
searchbtn.setOnClickListener(this);
}
public void onClick(View view) {
System.out.println("on click...");
String searchedText = input.getText().toString();
}
}
我无法弄清楚它有什么问题。任何建议都比欢迎。谢谢。
好像你还没有discouver logcat的。窗口 - >显示视图 - >'其他':Andoird - > LogCat在那里你会发现你的崩溃消息,它应该可以帮助你找到你的bug。使用Log.d(“你的标签”,“你的消息”)打印东西logcat – getekha 2010-11-25 20:19:01