我想在一个布局中使用两个按钮:问题在布局(Android)中创建了一个按钮?
- 一键票据,这是工作下面
- 一个按钮,计算器(button10)
我得到的超极本的错误.oncreate:
"The method onCreate(Bundle) is undefined for the type Object"
main.java:
public class IzzynActivity extends Activity{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button wg = (Button) findViewById(R.id.button1);
wg.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(IzzynActivity.this, notes.class);
IzzynActivity.this.startActivity(myIntent);
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button wg = (Button) findViewById(R.id.button10);
wg.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(IzzynActivity.this, calculator.class);
setResult(RESULT_OK, intent);
finish();
}
});
}
}
}
}
这里有什么问题? – 2012-03-04 17:57:06
每个活动只允许有一个onCreate方法。下面的两个答案将你的问题全部整理出来。也许你应该阅读一些HelloAndroid教程,以了解你在做什么。 – 2012-03-04 17:58:46