我有一个方法,当用户点击我的创建按钮时调用它,它调用一个方法名称 createEntry();
在此方法中,它会经过多次检查并根据结果返回 toasts 或错误,当它运行正确的结果时,它总是带我回到我的家庭活动,但如果出现错误,我希望它留在当前屏幕上,如何我可以这样做吗?
任何人都可以给我一些帮助吗?
public void onClick(View v) {
switch (v.getId()) {
case R.id.create_button:
Intent i = new Intent(this, Home.class);
createEntry();// this is where my error checking is done so what I would like to know is how can i stay on the current screen for certain errors
startActivity(i);
break;
}
}
}
如果出现错误,我不想加载主类,我希望它保留在当前屏幕上。