Solution:
To avoid that the listview component
public async Task Async_llenarListView(){
await Task.Run(() => {
string[] _equipos = { "Los Angeles Lakers", "Golden State Warriors", "Boston Celtics"};
for (int i = 0; i < _equipos.Length; i++){
_lista.Add(new model_equipos{
_id = i,
_source = "team" + (i + 1),
_nombreEquipo = _equipos[i],
_siglas = _siglas[i],
_votos = new Random().Next(0, 100) + ""
});
}
});
}`
To call a Page
private void mc_btn_sinCuentaAsync(object obj){
Application.Current.MainPage.Navigation.PushAsync(new mdp());
}
Wiht the slow scroll you used the ListViewCachingStrategy and set them with RecycleElement. And may be your ListView Scroll have a fluid scroll now.
I solved this problem by changing in Manifest file hardwareAccelerated
option to true
like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application android:hardwareAccelerated="true">
...
</application>
</manifest>
Fixing this requires identifying nodes where there is or possibly can happen long duration of processing. The best way is to do all the processing no matter how small or big in a thread separate from main UI thread. So be it accessing data form SQLite Database or doing some hardcore maths or simply sorting an array – Do it in a different thread
Now there is a catch here, You will create a new Thread for doing these operations and when you run your application, it will crash saying “Only the original thread that created a view hierarchy can touch its views“. You need to know this fact that UI in android can be changed by the main thread or the UI thread only. Any other thread which attempts to do so, fails and crashes with this error. What you need to do is create a new Runnable inside runOnUiThread and inside this runnable you should do all the operations involving the UI.
So we have Thread and Runnable for processing data out of main Thread, what else? There is AsyncTask in android which enables doing long time processes on the UI thread. This is the most useful when you applications are data driven or web api driven or use complex UI’s like those build using Canvas. The power of AsyncTask is that is allows doing things in background and once you are done doing the processing, you can simply do the required actions on UI without causing any lagging effect. This is possible because the AsyncTask derives itself from Activity’s UI thread – all the operations you do on UI via AsyncTask are done is a different thread from the main UI thread, No hindrance to user interaction.