2
I am trying to recover some information recorded in the database, only when an error happens, because I am trying to take an "integer" value and pass to "String", then I am not able to do this conversion, follow below the 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 mistake 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.
It worked, thank you for your attention!
– R. Oliveira
If this answer answered your question, click the tick symbol to mark it as correct and help other users.
– StatelessDev
What symbol would that be, so I can click???
– R. Oliveira
On the upper left side next to the answer, in gray, a symbol in the format of "right" which, when clicked, is in green. Accepting an answer as correct helps other users who have their doubts have confidence that that answer solved their problem and may solve theirs as well.
– StatelessDev
Got it and done, thanks!
– R. Oliveira