• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Resources$NotFoundException error

Lintz

Newbie
I'm getting a Resources$NotFoundException error when attempting to write text to a TextView after I have clicked on a button.

If I update the text within the click event it works OK but as soon as I attempt to update the text in a different method (called from within the click event) the error occurs.

Can someone help me solve this issue as I've been going round in circles on this for ages. Below is my code.

Thanks.

Code:
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        
        Button buttonCancel = (Button) findViewById(R.id.get_usage);
        buttonCancel.setOnClickListener(new OnClickListener() {
        @Override
            public void onClick(View v) {
            
       //The TextView updates fine if placed here
        TextView tv = (TextView) findViewById(R.id.Usage);
        tv.setText("Test123"); // updates OK without error

           //The error occurs in this method
            UpdateGUIWithUsageInformation("Testing123");

        });
    }

 private void UpdateGUIWithUsageInformation(String newText)
    {
       
        //Current Usage
        TextView tv = (TextView) findViewById(R.id.Usage);
        tv.setText(newText); // Error occurs on this line
}
This is from my main.xml.
Code:
<TextView
    android:text=""
    android:id="@+id/Usage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    </TextView>
 
Back
Top Bottom