In my application, I use a while loop . In each loop, I add a TableRow to the TableView
When the number of loops is large, an ANR occurs because MainThread is busy
I have tried using new Thread() but it didn’t work
I have tried using RecycleView but it didn’t work
Q1: Is it better to use TableView or RecycleView
Q2: Is there any suggestion that can help me solve the problem?
ANR: com.APPNAME.MainActivity.addTableRow
Crash: android.view.View.onRestoreInstanceState
Code Example in my app:
while ( i < loopNum ) {
Total = (NumberOne + NumberTwo);
//function to add addTableRow
addTableRow("i", "NumberOne","NumberTwo",Total)
NumberOne = Total
i++;
}
I have tried using new Thread() but it didn’t work
I have tried using RecycleView but it didn’t work
fekhreddine bouziane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
To display large collections in a grid it is best to use a RecyclerView with a GridLayoutManager (or a LinearLayoutManager with each item representing a table row, this will fit the Table use case better).
The RecyclerView will render only the necessary items every time and will reduce a lot of main thread work.
Please post your code if your’e having trouble with the RV implementation.