everybody!
I’m making a Android program and I need to list some texts on TableLayout during a for loop. The problem is that I have a lot of lines and I wanna add them gradually, to not look like slow, but the Android only call the invalidate() method on the end of loop.
my source below:
Handler handler = new Handler();
subcategoriasLayout.addView(tableLayout);
for (Product product : listProdutos) {
TableRow itemRow = new TableRow(this);
TextView descricao = new TextView(this);
descricao.setText(produto.toString());
itemRow.addView(descricao);
itemRow.addView(new EditText(this), rowLayoutParams);
tableLayout.addView(itemRow);
if (++cont % 10 == 0) {
handler.postDelayed(new Runnable() {
public void run() {
subcategoriasLayout.invalidate();
}
}, 10);
}
}
subcategoriasLayout.invalidate();
Thanks a lot
You should do the loading of all these things in an AsyncProcess so that it looks like its fluid instead of using a loop.