如何在android中让某件事持续下去直到它成为现实
好吧,在我的程序中,我有一些东西,当数据库 KEY_TITLE 为空时,它们会说某件事,直到用户进入主菜单执行某些操作。我的问题是如何检查它是否不再为空并继续该程序? 这是代码的一部分。
@Override
public void onClick(View v) {
insert.setText("");
text.setText(" Try it out! Go to the main menu and schedule a task!");
respond.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
mDbHelper2.fetchAllReminder();
if(TaskDbAdapter.KEY_BODY.isEmpty() ){
text.setText("Go and Schedule a task to continue =)!");
}else{
String task = new String(TaskDbAdapter.KEY_TITLE);
insert.setText("");
text.setText("text");
}
这是我的代码...一旦用户安排任务并返回活动并再次单击按钮,我就无法检查 KEY_TITLE 并执行其他操作。
Okay so in my program i have something that when the database KEY_TITLE is empty them it says a certain thing until the user goes till the main menu to do something. My question is how do i check to see if its not empty anymore and continue with the program?
Here is the part of code.
@Override
public void onClick(View v) {
insert.setText("");
text.setText(" Try it out! Go to the main menu and schedule a task!");
respond.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
mDbHelper2.fetchAllReminder();
if(TaskDbAdapter.KEY_BODY.isEmpty() ){
text.setText("Go and Schedule a task to continue =)!");
}else{
String task = new String(TaskDbAdapter.KEY_TITLE);
insert.setText("");
text.setText("text");
}
Here is my code... Im having trouble to check the KEY_TITLE and do the else once the user schedules a task and returns to the activity and clicks the button again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果“主菜单”是指应用程序之外的内容,那么您可以通过重写 Activity 中的
onResume()
来检查情况。如果它位于您的应用程序内部,则编写一个通知方法,并在执行用户应该执行的操作的代码实际运行时调用它。
If by "main menu" you mean something outside your app, then you can check the condition by overriding
onResume()
in your activity.If it's inside your app, then write a notification method and call it when the code that does whatever the user is supposed to do actually runs.