我只是在学习如何构建应用程序,我正在为绝对初学者使用安卓应用程序。在其中一个教程中,它要求我编写下面的代码,但出现错误:
setMessage(string) is undefined for the type MainActivity
现在代码完全按照书中所说的那样编写。任何帮助将非常感激,
public boolean onOptionsItemSelected(MenuItem Item) {
RelativeLayout bkgr = (RelativeLayout)findViewById(R.id.UiDesigns);
final
ImageView image=(ImageView)findViewById(R.id.imageView1);
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Pick an Image!");
.setMessage("Please Select Image One or Image Two:")
.setCancelable(false)
.setPositiveButton("IMAGE 1", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
image.setImageResource(R.drawable.image1);
}
})
.setNegativeButton("IMAGE 2", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id){
image.setImageResource(R.drawable.image2);
}
});