I’m new to JAva and Android, and I’m working on my first test app.
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) ;
}
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)
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 to display the value of a variable on the screen
Thanks
This line of procedural code:
appears in your class definition. It needs to appear within a method. It might need to be in a constructor.