1. Download our Official Android App: Forums for Android!

Apps Compilation error on my if else statement

Discussion in 'Android Development' started by isaacng88, Oct 5, 2011.

  1. isaacng88

    isaacng88 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Oct 5, 2011

    Oct 5, 2011
    1
    0
    5
    Hi,
    I've an error sntax on my 'else' in this if-else statement. anyone know why? Pls advise. thank you.

    source code:

    //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();
    //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));
    }
     

    Advertisement

  2. miXer

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    Syntax error is that it is semi-colon after the if and else if statements. Remove them and it will be okay.
     

Share This Page

Loading...