Please do not close it, IMHO this is a decent and, possibly, useful programming question.
Please, I read a lot of things, and I am embarrassed because I read different opinions and different approaches.
The problem is this:
in the getView() Adapter I need to perform some asynchronous operation, for example, check the formation on the Internet and update the view based on this.
I used the following approach:
every time getView() is called, I run a Thread
but my approach caused me a lot of criticism:
stack overflow
stack overflow
stack overflow
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { //... } else { //... } Thread th= new Thread(new Runnable() { @Override public void run() { mActivity.runOnUiThread(new Runnable() { @Override public void run() { CheckSomeInfoOverTheInternet(url, new myCallback { @Override public void onSuccess() { holder.textview.setText("OK"); } @Override public void onFailre() { holder.textview.setText("NOT OK!!!!"); } }); } }); } }); th.start(); return convertView; }
Please, what would be the best practice for this kind of action?
Please note: I am not looking for a solution to perform network requests in getView() , but rather, how to update the view depending on the result in an asynchronous call.
source share