0
我是Android Studio的新手。我正在學習通過developer.android.com進行編程。我正在添加操作欄,但現在我正面臨一個錯誤。在MainyActivity.java中設置搜索和設置代碼時出錯
`
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_search:
private void openSearch() {
Toast.makeText(this, "Search button pressed", Toast.LENGTH_SHORT).show();
}
return true;
case R.id.action_settings:
private void openSettings() {
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
這裏是我的代碼,openSearch()
和openSettings()
後,我得到錯誤添加「;」`但是當我添加它,它再次顯示了表達的預期。請儘快幫助我。提前致謝!
謝謝JozeRi,即工作!非常感謝。 :) –
高興幫忙:)快樂編碼! – JozeRi