我的活动中有片段,我想通过菜单刷新页面
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item_delete:
// refrash page
if(db.getAllDataBuyit().size()>0) {
db.RemoveBuy_AllItem();
startActivity(getIntent());
}
return true;
default:
}
return super.onOptionsItemSelected(item);
}
答案 0 :(得分:0)
嗨,您可以在完成后执行startActivity;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item_delete:
// refrash page
if(db.getAllDataBuyit().size()>0) {
db.RemoveBuy_AllItem();
/////////////////////////
finish();
startActivity(getIntent());
/////////////////////////
}
return true;
default:
}
return super.onOptionsItemSelected(item);
}
答案 1 :(得分:0)
Intent i = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
startActivity(i);