3
我的Android应用中的按钮的onClick()事件不会触发。该按钮是一系列配置活动中的一个活动中的“下一个”按钮。第一次经历一系列配置活动时,onClick()事件触发正常。但是,如果我从应用程序中退出(使用后退按钮)并重新启动,则该事件不会触发。我通过在我的next()方法中放置一个断点来验证;调用后续活动的方法。Android按钮点击事件有时不会触发
这里是我的代码:
按钮XML在我的布局:
<Button
android:id="@+id/gender_button_id"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:onClick="next"
android:text="@string/gender_button" />
活动代码:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gender);
}
public void next(View view)
{
Intent i = new Intent(this, WeightActivity.class);
startActivity(i);
}
你可以发布你的日志条目,当按钮不工作吗? – jamesc
我从哪里得到这个信息? – Vinnie
哈哈!学习如何读取日志输出对于开发Android应用程序至关重要。您可以从命令行运行adb logcat,或者在代码窗口下方的logcat输出选项卡中查看Eclipse中的输出。 – jamesc