Android resource not found exception?

前端 未结 9 671
一生所求
一生所求 2020-11-28 12:11

I am having a strange problem using findViewById(id). It comes back with resource not found even though the resource is definitely there. It is a textview in a layout next t

9条回答
  •  借酒劲吻你
    2020-11-28 13:06

    Exception Message thrown is not very descriptive. Its very much likely the case you are trying to cast the int value to String, applying the below change fixed the issue for me.

    Code before the fix:

     itemPrice.setText(foodMenuItems.get(position).getItemPrice());
    

    Code after the fix:

     itemPrice.setText(Integer.toString(foodMenuItems.get(position).getItemPrice()));
    

提交回复
热议问题