嗨,我是 android dev 的新手,以下代码给出错误 1) 对象类型的 onCreate(bundle) 方法未定义 2) DisplayMessageActivity 类型的方法 onCreate(bundle) 必须被覆盖或实现我正在使用的超类型方法 super .onCreate 但它给了我这个错误?
public class DisplayMessageActivity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(null);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
((Object) getActionBar()).setDisplayHomeAsUpEnabled(true);
}
}
private void setContentView(TextView textView) {
// TODO Auto-generated method stub
}
private Intent getIntent() {
// TODO Auto-generated method stub
return null;
}
private Object getActionBar() {
// TODO Auto-generated method stub
return null;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}