我一直在遵循它,并且我被困在了3个文本视图错误教程中:http://developer.android.com/training/basics/firstapp/starting-activity.html我得到了2个错误,说textview不能被解析,还有一个说textView不能作为变量解析。帮助!
@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(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
setContentView(R.layout.activity_display_message);
// Show the Up button in the action bar.
setupActionBar();`
发布于 2013-07-23 03:08:18
您已将其声明为textview (小写"v"),但将其引用为textView (大写"v")。选一个吧!
TextView textView = new TextView(this); // Change the "v" to uppercase
textView.setTextSize(40);
textView.setText(message);发布于 2013-07-23 03:07:47
Variables in Java are case sensitive,所以textView和textview是不同的。将您的代码更改为:
TextView textview = new TextView(this);
textview.setTextSize(40);
textview.setText(message);
// Set the text view as the activity layout
setContentView(textview);https://stackoverflow.com/questions/17795418
复制相似问题