错误(';'预计在第25行)

时间:2015-06-14 19:28:51

标签: android-studio

我的老师希望我们在Android Studio上制作应用,所以我选择制作音乐应用。

package com.example.laura.homework;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends Activity {

MediaPlayer mustafa1;
MediaPlayer mustafa2;
MediaPlayer tarkan1;
MediaPlayer tarkan2;
MediaPlayer tarkan3;
MediaPlayer tarkan4;
MediaPlayer tarkan5;
MediaPlayer tarkan6;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mustafa1 = MediaPlayer.create(this,R.raw.aya_benzer_mustafa_sandal)
    mustafa2 = MediaPlayer.create(this,R.raw.melek_yuzulum_mustafa_sandal)
    tarkan1 = MediaPlayer.create(this,R.raw.simarik_tarkan)
    tarkan2 = MediaPlayer.create(this,R.raw.adimi_kalbine_yaz_tarkan)
    tarkan3 = MediaPlayer.create(this,R.raw.dudu_tarkan)
    tarkan4 = MediaPlayer.create(this, R.raw.kuzu_kuzu_tarkan)
    tarkan5 = MediaPlayer.create(this,R.raw.yemin_ettim_tarkan)
    tarkan6 = MediaPlayer.create(this, R.raw.op_tarkan)
}


@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 SimplifiableIfStatement
    if (id == R.id.action_settings) {
    return true;
    }

    return super.onOptionsItemSelected(item);
    }
    }
 package com.example.laura.homework;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends Activity {

MediaPlayer mustafa1;
MediaPlayer mustafa2;
MediaPlayer tarkan1;
MediaPlayer tarkan2;
MediaPlayer tarkan3;
MediaPlayer tarkan4;
MediaPlayer tarkan5;
MediaPlayer tarkan6;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mustafa1 = MediaPlayer.create(this,R.raw.aya_benzer_mustafa_sandal)
    mustafa2 = MediaPlayer.create(this,R.raw.melek_yuzulum_mustafa_sandal)
    tarkan1 = MediaPlayer.create(this,R.raw.simarik_tarkan)
    tarkan2 = MediaPlayer.create(this,R.raw.adimi_kalbine_yaz_tarkan)
    tarkan3 = MediaPlayer.create(this,R.raw.dudu_tarkan)
    tarkan4 = MediaPlayer.create(this, R.raw.kuzu_kuzu_tarkan)
    tarkan5 = MediaPlayer.create(this,R.raw.yemin_ettim_tarkan)
    tarkan6 = MediaPlayer.create(this, R.raw.op_tarkan)
}


@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 SimplifiableIfStatement
    if (id == R.id.action_settings) {
    return true;
    }

    return super.onOptionsItemSelected(item);
    }
    }

我得到了,在我的错误中“藏匿”,“';'预期(第25行)“等等。我需要帮助来解决这个问题。有什么建议吗?

2 个答案:

答案 0 :(得分:2)

包括;第25行及以后的结尾

mustafa1 = MediaPlayer.create(this,R.raw.aya_benzer_mustafa_sandal);
mustafa2 = MediaPlayer.create(this,R.raw.melek_yuzulum_mustafa_sandal);
tarkan1 = MediaPlayer.create(this,R.raw.simarik_tarkan);
tarkan2 = MediaPlayer.create(this,R.raw.adimi_kalbine_yaz_tarkan);
tarkan3 = MediaPlayer.create(this,R.raw.dudu_tarkan);
tarkan4 = MediaPlayer.create(this, R.raw.kuzu_kuzu_tarkan);
tarkan5 = MediaPlayer.create(this,R.raw.yemin_ettim_tarkan);
tarkan6 = MediaPlayer.create(this, R.raw.op_tarkan);

答案 1 :(得分:0)

好的,所以我认为你的b / c没有用;结束任何这些陈述:

mustafa1 = MediaPlayer.create(this,R.raw.aya_benzer_mustafa_sandal) mustafa2 = MediaPlayer.create(this,R.raw.melek_yuzulum_mustafa_sandal) tarkan1 = MediaPlayer.create(this,R.raw.simarik_tarkan) tarkan2 = MediaPlayer.create(this,R.raw.adimi_kalbine_yaz_tarkan) tarkan3 = MediaPlayer.create(this,R.raw.dudu_tarkan) tarkan4 = MediaPlayer.create(this, R.raw.kuzu_kuzu_tarkan) tarkan5 = MediaPlayer.create(this,R.raw.yemin_ettim_tarkan) tarkan6 = MediaPlayer.create(this, R.raw.op_tarkan)