2011-10-06 10 views
0

Eclispeコンパイラは、else else文にエラーsntaxを表示します。誰が何が間違っているのか教えてくれますか?ありがとう!Android:if else文のコンパイルエラー

コード

//click on one of chapters 
    list.setOnItemClickListener(new OnItemClickListener() 
    { 
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
     { 

      String item = ((TextView)view).getText().toString(); 

      Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show(); 

      //Choose Chapter 1 
      if (item.equalsIgnoreCase("I. The Global Business Environment")); { 
      //go to chapter 1 
      startActivity(new Intent(ChaptersActivity.this, Chapter1Activity.class)); 
      } else if (item.equalsIgnoreCase("II. Information Systems")); { 
       //go to chapter 2 
       startActivity(new Intent(ChaptersActivity.this, Chapter2Activity.class)); 
      } 

      //Choose Chapter 3 
      else if (item.equalsIgnoreCase("III. Operations Management")); 
      { 
       //go to chapter 3 
       startActivity(new Intent(ChaptersActivity.this, Chapter3Activity.class)); 
      } 

      //Choose Chapter 4 
      else if (item.equalsIgnoreCase("IV. Marketing")); 
      { 
       //go to chapter 4 
       startActivity(new Intent(ChaptersActivity.this, Chapter4Activity.class)); 
      } 

      //Choose Chapter 5 
      else if (item.equalsIgnoreCase("V. Managing Human Capital")); 
      { 
       //go to chapter 5 
       startActivity(new Intent(ChaptersActivity.this, Chapter5Activity.class)); 
      } 

      //Choose Chapter 6 
      else if (item.equalsIgnoreCase("VI. Preparing for the Examination")); 
      { 
       //go to chapter 6 
       startActivity(new Intent(ChaptersActivity.this, Chapter6Activity.class)); 
      } 
     } 
    }); 

彼らは '他の' コード・ワード、任意のアイデアにエラーsntaxを表示しますか?

+0

これを行うより良い方法は、あなたのビューでid属性を使用し、view.getId()を呼び出してswitch文に入れることです。 – Merlin

答えて

4

あなたの場合の条件の終わりにsemicolonを持っている:

if (item.equalsIgnoreCase("I. The Global Business Environment")); { 

if文を終了し、{どこからともなく現れ、その後他、新鮮なブロックを開始します。

+0

ありがとう!見つけた答え – user975057

0

;はすべてif-elseの条件文に現れます。