Good day programming warriors, please help me to this simple problem of mine, i'm new to android. How can I How to convert TextView value to Integer. please see my attached codes, thank you.
public class appleTrivia extends AppCompatActivity {
public int total = 0;
public int score = 40;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple_trivia);
TextView scoreLabel = (TextView) findViewById(R.id.labelScore);
scoreLabel.setText("Score: " + score);
scoreLabel.setText("Score: " + getIntent().getExtras().getInt("points", 0));
try {
total = Integer.parseInt("score: " + scoreLabel);
}
catch (NumberFormatException nfe )
{
}
}
public void onClickProceed (View view) {
Intent intent = new Intent(this, cherry.class);
startActivity(intent);
Toast.makeText(appleTrivia.this, "Your score is:" + total, Toast.LENGTH_LONG).show();
}
}
I need to convert scoreLabel value to integer so I can add it to another score, thank you. PS. Toast.makeText(appleTrivia.this, "Your score is:" + total, Toast.LENGTH_LONG).show(); give's me 0 score.