I'm trying to retrieve some information stored in the database, but when it's done an error occurs, since I'm trying to get an "integer" value and pass it to "String", there I can not do this conversion, codes:
public class ProdutoAdapter extends ArrayAdapter<Produto> {
private final Context context;
private final ArrayList<Produto> elementos;
public ProdutoAdapter(Context context, ArrayList<Produto> elementos) {
super(context, R.layout.linha_produtos, elementos);
this.context = context;
this.elementos = elementos;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.linha_produtos, parent, false);
TextView id = (TextView) rowView.findViewById(R.id.txtId);
TextView descricao = (TextView) rowView.findViewById(R.id.txtDesc);
TextView preco = (TextView) rowView.findViewById(R.id.txtVVenda);
TextView estoque = (TextView) rowView.findViewById(R.id.txtEstoque);
id.setText(Integer.parseInt(elementos.get(position).getId()));
descricao.setText(elementos.get(position).getDescricao());
preco.setText(elementos.get(position).getValorVenda());
estoque.setText(elementos.get(position).getEstoqueAtual());
return rowView;
}
The error happens here id.setText(Integer.parseInt(elementos.get(position).getId()));
Here is the error code:
android.content.res.Resources$NotFoundException: String resource ID #0x1
at android.content.res.Resources.getText(Resources.java:338)
at android.widget.TextView.setText(TextView.java:5494)
at com.example.rodrigoconceicao.controleestoque2_1.ProdutoAdapter.getView(ProdutoAdapter.java:32)
Note: The "ID" object is declared as "INT" in the class.