@Override
public void onBackPressed(){
if (back_pressed + 2000 > System.currentTimeMillis()){
Homepage1.super.onBackPressed();
}
else{
Toast.makeText(getBaseContext(), "Press once again to exit", Toast.LENGTH_SHORT).show();
back_pressed = System.currentTimeMillis();
}
}
错误:(51,42)错误:';'预期错误:任务执行失败 ':应用程序:compileDebugJavaWithJavac'。编译失败;看到编译器 错误输出以获取详细信息。
答案 0 :(得分:0)
将此方法放在Activity
类中。
public class MyActivity extends AppCompatActivity {
@Override
public void onBackPressed() {
if (back_pressed + 2000 > System.currentTimeMillis()){
Homepage1.super.onBackPressed();
}
else{
Toast.makeText(getBaseContext(), "Press once again to exit", Toast.LENGTH_SHORT).show();
back_pressed = System.currentTimeMillis();
}
}
}