I always get a Resources$NotFoundException but i don't know why. Please help
Code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = new ViewHolder();
LayoutInflater li = (LayoutInflater)CustomAdapter.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = li.inflate(R.layout.customlistitem,null);
holder.mTexttitle = (TextView) convertView.findViewById(R.id.item_title);
holder.mTextrate = (TextView) convertView.findViewById(R.id.item_rate);
convertView.setTag(holder);
}
else{
holder = (ViewHolder) convertView.getTag();
}
holder.mTexttitle.setText(pizzen.get(position).title);
holder.mTextrate.setText(pizzen.get(position).rate);
//holder.mTextdate.setText(pizzen.get(position).date.toString());
return convertView;
}
public class ViewHolder {
public TextView mTexttitle;
public TextView mTextrate;
public TextView mTextdate;
public ImageView mImageView;
}
Stacktrace:
09-30 10:11:07.001: ERROR/XXX List View(1032): android.widget.ListView@43d133c0
09-30 10:11:07.021: ERROR/XXX(1032): Courser Enter: EditText
09-30 10:11:07.031: ERROR/XXX(1032): Count:1
09-30 10:11:07.031: ERROR/XXX(1032): Item[0] -->com.korn.pizzacounter.Pizza@43d16468
09-30 10:11:07.031: ERROR/XXX(1032): 1
09-30 10:11:07.101: ERROR/AndroidRuntime(1032): Uncaught handler: thread main exiting due to uncaught exception
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): android.content.res.Resources$NotFoundException: String resource ID #0x2
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at android.content.res.Resources.getText(Resources.java:200)
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at android.widget.TextView.setText(TextView.java:2813)
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at com.korn.pizzacounter.CustomAdapter.getView(CustomAdapter.java:44)
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at android.widget.AbsListView.obtainView(AbsListView.java:1274)
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at android.widget.ListView.makeAndAddView(ListView.java:1668)
09-30 10:11:07.121: ERROR/AndroidRuntime(1032): at android.widget.ListView.fillDown(ListView.java:637)
holder.mTextrate.setText(pizzen.get(position).rate);
If rate
is int, then android thinks you passed resource id and tries to find resource. You need explicitly convert int to String: String.valueOf(pizzen.get(position).rate)
Is rate
really int?
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