您好我是android dev的新手,下面的代碼給出了錯誤 1)方法onCreate(bundle)未定義爲對象類型 2)方法onCreate捆綁)類型DisplayMessageActivity必須重寫或實現一個超類型方法 我使用super.onCreate但它給了我這個錯誤?onCreate(bundle)的方法未定義爲對象類型
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);
}
}
我正在使用本教程http://developer.android.com/training/basics/firstapp/starting-activity.html –
[Android Activity中的方法未定義錯誤]的可能重複(http://stackoverflow.com/ question/21067653/method-undefined-error-in-android-activity) – codeling
@RandolphCarter通常,新問題應該被標記爲舊的而不是其他方式的副本。 – laalto