Note that there are some explanatory texts on larger screens.

plurals
  1. POBug in Listview. When I roll my list view, the imageview is changing by it self. What was my mistake?
    primarykey
    data
    text
    <p>In my method that getView: </p> <pre><code> public View getView(int index, View view, ViewGroup parent) { if (view == null) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); view = inflater.inflate(R.layout.linha_historico_layout, parent, false); } DadosHistorico dadosHistorico = (DadosHistorico) getItem(index); TextView tvdata = (TextView) view.findViewById(R.id.tvData); tvdata.setText(dadosHistorico.getData()); TextView ivstatushistorico = (TextView) view.findViewById(R.id.tvStatushistorico); ivstatushistorico.setText(dadosHistorico.getStatus()); TextView tvInternetTitlo = (TextView) view.findViewById(R.id.tvInternetTitulo); tvInternetTitlo.setText(dadosHistorico.getInternet()); TextView tvLigacaoTitulo = (TextView) view.findViewById(R.id.tvLigacaoTitulo); tvLigacaoTitulo.setText(dadosHistorico.getLigacao()); TextView tvInternetDescricao = (TextView) view.findViewById(R.id.tvInternetDescricaoHistorico); tvInternetDescricao.setText(dadosHistorico.getInternetDescricao()); TextView tvLigacaiDescricao = (TextView) view.findViewById(R.id.tvLigacaoDescricaoHistorico); tvLigacaiDescricao.setText(dadosHistorico.getLigacaoDescricao()); TextView tvComentarioHistorico = (TextView)view.findViewById(R.id.tvComentarioHistorico); tvComentarioHistorico.setText(dadosHistorico.getComentario()); final String comentario = tvComentarioHistorico.getText().toString(); ImageView ivStatusLed = (ImageView) view.findViewById(R.id.ivStatusLe); if(ivstatushistorico.getText().equals("1")){ ivStatusLed.setBackgroundResource(R.drawable.green_led); ivStatusLed.setVisibility(View.VISIBLE); } ImageView ibComentarioHistorico = (ImageView)view.findViewById(R.id.ibComentarioHistorico); if(comentario.equals("")){ ibComentarioHistorico.setVisibility(View.INVISIBLE); }else{ ibComentarioHistorico.setVisibility(View.VISIBLE); } ibComentarioHistorico.setOnClickListener(new OnClickListener() { public void onClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(c).create(); alertDialog.setTitle("Comentário"); alertDialog.setMessage(comentario); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } }); return view; } public void addDados(String data, String status, String internet, String internetDescricao, String ligacao, String ligacaoDescricao, String comentario) { dados.add(new DadosHistorico(data, status, internet, internetDescricao, ligacao, ligacaoDescricao, comentario)); } } </code></pre> <p>In this code I change the imageview that is in my list. I receive some data from a database and change the imageview. The problem is, when I scroll down the listview and scroll back, the imageview are different, some time is gream_led, and some time the ibComentarioHistorico disappear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload