2016-05-19 8 views
2

を見つけることができませんか?私はこの部分については同様のエラーmesaageを得ていたエラー: <blockquote> <p>"cannot find symbol variable action_settings"</p> </blockquote> <p></p>がどのように私はこの問題を解決することができます:私は、エラーメッセージが出続けるシンボル変数action_settings

.inflate(R.menu.menu_main, menu); 

が、その後、私は解像度ファイルのメニューファイルを追加する方法について、ここで誰かからの助言に従いました。

この状況についてどうすればよいですか?

package com.example.android.courtcounter; 
 

 
import android.os.Bundle; 
 
import android.support.v7.app.AppCompatActivity; 
 
import android.view.Menu; 
 
import android.view.MenuItem; 
 
import android.view.View; 
 
import android.widget.TextView; 
 

 
/** 
 
* This activity keeps track of the basketball score for 2 teams. 
 
*/ 
 
public class MainActivity extends AppCompatActivity { 
 

 
    // Tracks the score for Team A 
 
    int scoreTeamA = 0; 
 

 
    // Tracks the score for Team B 
 
    int scoreTeamB = 0; 
 

 
    
 
    @Override 
 
    public boolean onCreateOptionsMenu(Menu menu) { 
 
     // Inflate the menu; this adds items to the action bar if it is present. 
 
     getMenuInflater().inflate(R.menu.menu_main, menu); 
 
     return true; 
 
    } 
 

 
    @Override 
 
    public boolean onOptionsItemSelected(MenuItem item) { 
 
     // Handle action bar item clicks here. The action bar will 
 
     // automatically handle clicks on the Home/Up button, so long 
 
     // as you specify a parent activity in AndroidManifest.xml. 
 
     int id = item.getItemId(); 
 

 
     //noinspection SimpSlifiableIfStatement 
 
     if (id == R.id.action_settings) { 
 
      return true; 
 
     } 
 

 
    } 
 
}

+0

輸入R.id.action_settings行を削除しますか?それとも宣言しますか? – markspace

+0

文を検証してaction_settingsメニューオプションを作成するためには、 "main_menu"宣言のXMLリソースを参照する必要があります – JCricket

答えて

0

あなたのメニューmenu_mainは、特定のビュー(ID = action_settings)を含まなければならない.ORあなただけ

if (id == R.id.action_settings) 
関連する問題

 関連する問題