0
我想做一个示例项目,但我有错误。对于应用程序开发来说,我非常新,对于IT来说确实如此,但并不是新鲜事。我正在学习一个教程,但教师使用的eclipse和ADT版本相当古老而且不同。Main.this有修复这个问题
因为我能够得到的,因为我有编程经验的它周围的大部分,但我不能过去,这和我需要之前,我继续前进,该错误信息是这样的
“主不能被解析为一个类型”
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.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 b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(main.this, second.class));
}
});
}
}
的东西是教练做了完全一样的,并没有任何问题,我在想它做他用的是旧版本的东西。
帮助任何人?
感谢
这与版本无关。此代码不适用于任何版本。范围内没有变量,名为'main'。要么你遗漏了一些东西,或者教程中的代码不正确。 – Simon