0
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中定義,否則你不能調用函數嗎?無法從內部調用函數onOptionsItemSelected
調用該函數時,我得到一個nullPointer異常。
確切定義了「SetImageView」的位置?此活動之外?你得到的全部錯誤是什麼? – Ralgha
發佈您的logcat,以便我們可以爲您提供幫助。 – caiocpricci2