问题描述
我是新来的Java和Android,和我的工作我的第一个测试应用程序。
I'm new to JAva and Android, and I'm working on my first test app.
我有这样的code(这是整个code):
I have this code (This is the whole code):
package test.test;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
int num_seeds = 15 ;
int num_coins = 100 ;
int seed_buy_price = 10 ;
int seed_sell_price = 8 ;
String S_num_seeds = Integer.toString(num_seeds) ;
TextView textView_seeds_current_display = (TextView) findViewById(R.id.textView_seeds_current_display) ;
textView_seeds_current_display.setText(S_num_seeds) ;
}
但是Eclipse显示我的最后一行的错误:
在该行多个标记
- 令牌S_num_seeds语法错误,VariableDeclaratorId预计在此之后
象征
- 令牌(S),错位结构(S)语法错误
But Eclipse shows me an error on last line:Multiple markers at this line - Syntax error on token "S_num_seeds", VariableDeclaratorId expected after this token - Syntax error on token(s), misplaced construct(s)
我是新来的Java,我仍然无法理解这个相当不错。可能有人请点我什么我做错了吗?我想我从这里以下的建议:
I'm new to Java and I still can not understand this quite well. Could somebody please point me what am I doing wrong? I think I'm following the advice from here:
How到屏幕显示一个变量的值
感谢
推荐答案
这行程序code的:
textView_seeds_current_display.setText(S_num_seeds);
出现在你的类定义。它需要在方法中出现。它可能需要在一个构造函数。
appears in your class definition. It needs to appear within a method. It might need to be in a constructor.
这篇关于VariableDeclaratorId和错位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!