为了练习,我在https://developer.android.com/training/basics/firstapp/index.html上做了"构建你的第一个应用程序"的例子. 现在我对Intents有问题.Eclipse说"无法访问的代码"我已经导入了类Intent(import android.content.Intent;)
Intent intent = getIntent();
Run Code Online (Sandbox Code Playgroud)
这是代码:
package com.example.test;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.annotation.TargetApi;
import android.os.Build;
import android.content.Intent;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
// Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
} …Run Code Online (Sandbox Code Playgroud)