public boolean onOptionsItemSelected(MenuItem item)
{
//check selected menu item
switch (item.getItemId()) {
case R.id.exit:
this.finish();
return true;
case R.id.basic:
Difficulty = DIFFICULTY_BASIC;
Toast.makeText(YogaPosesActivity.this, "Difficulty is Basic", Toast.LENGTH_SHORT).show();
SetImageView(myDbHelper);
return true;
case R.id.advanced:
Toast.makeText(YogaPosesActivity.this, "Difficulty is Advanced", Toast.LENGTH_SHORT).show();
Difficulty = DIFFICULTY_ADVANCED;
SetImageView(myDbHelper);
return true;
case R.id.allPoses:
Toast.makeText(YogaPosesActivity.this, "All Poses Will Be Displayed", Toast.LENGTH_SHORT).show();
Difficulty = DIFFICULTY_ADVANCED_AND_BASIC;
SetImageView(myDbHelper);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
调用 SetImageView 函数时出现错误,该函数是在 OnCreate Activity 之外定义的。除非在 OnCreate 中定义,否则不能调用函数吗?
调用函数时出现 nullPointer 异常。