我正在尝试为 Android 构建一个带有“播放”按钮的简单应用程序。在 MainActivty.java 文件中,我收到以下代码错误,那么我需要在这里纠正什么?
package com.example.simplemusicplayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Button playButton=(Button) findViewById(R.id.button1);
playButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
//TODO Auto generated method stub
Toast.makeText(MainActivity.this,"Starting to play",Toast.LENGTH_SHORT).show();
}
});
}
}