ResourceNotFoundException - String Resource Identifier

07-25 10:15:37.960: E/AndroidRuntime(8661): android.content.res.Resources$NotFoundException: String resource ID #0x7 07-25 10:15:37.960: E/AndroidRuntime(8661): at android.content.res.Resources.getText(Resources.java:230) 

Good day to everyone.

I am trying to show an integer value in a text representation and the above error appears in LogCat.

There are other similar reports about this problem; for example, and, but none of the solutions worked for me.

Any other ideas on what might be the issue?

Edited for code:

 private static Button btnCancel; private static Button btnConfirm; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtRoomNumber = (EditText)findViewById(R.id.txtRoomNumber); btnCancel = (Button)findViewById(R.id.btnCancel); btnConfirm = (Button)findViewById(R.id.btnConfirm); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); System.exit(0); } }); btnConfirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int rmNo = getRoomNumberValue(); txtTesting.setText(rmNo); } }); } private int getRoomNumberValue() { int temp = 0; try { temp = Integer.parseInt(txtRoomNumber.getText().toString()); } catch(Exception e) { e.printStackTrace(); } return temp; } 
+6
source share
4 answers

If you are trying to display an integer value in a TextView , use this:

 myTextView.setText("" + 1); // Or whatever number 

The error occurs because TextView has a different method: setText(int resid) . This method looks for a resource identifier that is not in your case. Link

+14
source

You are trying to set the text text of a TextView with an integer value.

The problem is that the method you are using is expecting a resource identifier.

You need to make a String from your integer before putting it into a TextView:

 textView.setText(Integer.toString(7)); 
+3
source

Change integer to string

 textview.setText(String.valueOf(valueofint)); 
+2
source

To convert an integer to string use

 int x=10; Integer.toString(x); 

This will solve your problem.

+2
source

Source: https://habr.com/ru/post/950235/


All Articles