Here is my question and its solution regarding this problem..
Em trying to pass textview value between different activities, and em getting a problem. when i execute the code, the app crashes on opening StudentActivity, but then it shows the correct result..here is the code
LoginActivity.java
int a = Integer.parseInt(textView.getText().toString());
Intent i = new Intent(LoginActivity.this, StudentActivity.class);
i.putExtra("level", a);
startActivity(i);
StudentActivity.java
textView.setText(Integer.toString(getIntent().getExtras().getInt("level")));
IN studentActivity, Integer.toString(getIntent().getExtras().getInt("level")) => this line says Number formatting does not take into account locale settings. Consider using String.format instead.Please suggest some code.. Any help would be truely appreciated!!
Regarding the warning :
"Number formatting does not take into account locale settings. Consider using String.format instead android studio",
This is a Lint warning called "TextView Internationalization" which says :
When calling TextView#setText * Never call Number#toString() to format numbers; it will not handle fraction separators and locale-specific digits properly. Consider using String#format with proper format specifications (%d or %f) instead.
So you should have written :
textView.setText(String.format("%d", getIntent().getExtras().getInt("level"))));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With