I have a TabLayout
consisting of 6 fragments, controlled by a ViewPager
. Its function is to look up a word in one (or more) dictionary onlines, each online dictionary represented by the tab. Once I have the word to look up, I launch multiple DictAsyncTask
in parallel via this code:
dictAsyncTask = new DictAsyncTask(DictionaryLookUp.this, "Tatoeba");
dictAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dictAsyncTask = new DictAsyncTask(DictionaryLookUp.this, "Jukuu");
dictAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
dictAsyncTask = new DictAsyncTask(DictionaryLookUp.this, "Weblio");
dictAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Up to now, I had a single ProgressBar
, but I would prefer to have one ProgressBar
per tab header (since some downloads take longer than others).
I found this snippet on SO and it currently is associated with my main RelativeLayout
:
progressBar = new ProgressBar(DictionaryLookUp.this,null,android.R.attr.progressBarStyleHorizontal);
RelativeLayout rlvDictionaryLookUp = (RelativeLayout) findViewById(R.id.rlvDictionaryLookUp);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
rlvDictionaryLookUp.addView(progressBar,params);
progressBar.setVisibility(View.VISIBLE);
before I paste more code, would it be possible to create e.g. 3 ProgressBar
objects and associated them and locate them on top of the corresponding tab header: