In the / res / values ​​folder of my android project, I have a line referenced by a text view in my XML file, I want to change the line in my java file.
As you can see below in the code, I made a string variable, and then below what I set, for which the string variable is set, where is the string. where I have the "here" in the code, where I want to change the line in the values ​​folder. but I don’t know what code to use to install it.
I could just change the text in the text view from my java file, which I know how to do, but this is the old way and warning sets, so I would prefer to use the line that is the best way to do this.
With my knowledge of changing text in a textual representation, I basically guessed about my path to this stage, but I don’t know how to go further, can someone give me some advice on what to do, thanks.
String string; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); counter = 0; add = (Button) findViewById(R.id.badd); sub = (Button) findViewById(R.id.bsub); reset = (Button) findViewById(R.id.breset); display = (TextView) findViewById(R.id.tvdisplay); string = (String) getString(R.string.counter); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ((///////////////here////////////////)) counter++; } });
source share