Answer the question
In order to leave comments, you need to log in
How to display given value in TextView?
Good day to all. I have such a problem. I am unable to display the given value in the TextView. There is a str variable equal to 100, as soon as I try to display it in Anfdroid, the application immediately closes. In fact, it doesn't even start. Isn't it possible to deduce the value this way?
public class MainActivity extends Activity implements OnClickListener{
Button button1;
EditText edittext;
TextView textview, textview2;
public int str = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Находим элементы по ID
button1 = (Button) findViewById(R.id.button1);
edittext = (EditText) findViewById(R.id.editText1);
textview = (TextView) findViewById(R.id.textView1);
textview2 = (TextView) findViewById(R.id.textView2);
// Присваиваем размер депозита
textview2.setText(str); - ЗДЕСЬ ВОЗНИКАЕТ ОШИБКА
}
Answer the question
In order to leave comments, you need to log in
Logcat is great at pointing out the error. The line "Caused by ... Resources$NotFoundException: String resource ID #0x64" means that you are calling the following method:
public final void setText(int resid) {
setText(getContext().getResources().getText(resid));
}
Check out - stackoverflow.com/questions/3275467/why-cant-i-set...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question