如果记录计数等于或大于5,我正在尝试使用以下代码来显示一个意图;如果在仪表板布局的第一个按钮上记录计数小于5,则尝试使用不同的意图。
然而,无论记录计数如何,只有记录计数小于5时才会进入Demo.Class而不是one.class ...... GetCount是什么问题????
private class DashboardClickListener implements OnClickListener {
// @Override
public void onClick(View v) {
Intent i = null;
switch (v.getId()) {
case R.id.dashboard_button_one:
if (mDbHelper.fetchAllNotes().getCount() >= 5) {
i = new Intent(DashboardActivity.this, Demo.class);
}
else if (mDbHelper.fetchAllNotes().getCount() < 5) {
i = new Intent(DashboardActivity.this, one.class);
}
break;
case R.id.dashboard_button_two:
i = new Intent(DashboardActivity.this, two.class);
break;
case R.id.dashboard_button_three:
i = new Intent(DashboardActivity.this, three.class);
break;
case R.id.dashboard_button_four:
i = new Intent(DashboardActivity.this, four.class);
break;
default:
break;
}
if(i != null) {
startActivity(i);
}
}
}