-2

私は比較的初心者であり、自分のコードの何が問題なのかを突き止めようと、いろいろと調べています。サブリストに分割される基本的なリストビュー用です

   ListView localListView = (ListView)findViewById(2131361899);
    localListView.setAdapter(new ArrayAdapter(this, 2130903117, arrayOfString));
    localListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
//Start//
      public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
      {
        String str = ((TextView)paramView).getText().toString();
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230721)))
          ChapterList.this.startActivity(new Intent(ChapterList.this, Foreword.class));
        while (true)
        {return;
        //The Error starts here//
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230723)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter1Section.class));
          continue;
        }
          //And ends here//
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230728)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter2Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230745)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter3Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230752)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter4Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230759)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter5Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230764)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter6Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230765)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter7Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230768)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter8Section.class));
          continue;
        }
        if (str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230778)))
        {
          ChapterList.this.startActivity(new Intent(ChapterList.this, Chapter9Section.class));
          continue;
        }
        if (!str.equalsIgnoreCase(ChapterList.this.getResources().getString(2131230722)))
          continue;
        ChapterList.this.startActivity(new Intent(ChapterList.this, Appendix.class));
        }
      }
4

1 に答える 1

1

ステートメントの後のコードにはreturn;到達しません。while ループ ブロック内では、各ステートメントが一度に 1 つずつ評価されます。ただし、return;ステートメントが評価されると、メソッド全体が呼び出し元のメソッドに制御を「戻し」、そのメソッドでそれ以上コードが実行されなくなります。

于 2012-04-13T18:05:42.940 に答える