android


Webservice call on current displayed fragment viewpager?


I have view pager with 5 fragments.
On all the fragments I have 5 different web services to call.
When the app is launched all the 5 fragments web services are triggered.
Where as only the current displayed fragment's web service should be called.
How to fix this? What is the solution for it?
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
adapter.addFragment(new AppFragment1());
adapter.addFragment(new AppFragment2());
adapter.addFragment(new AppFragment3());
adapter.addFragment(new AppFragment4());
adapter.addFragment(new AppFragment5());
viewPager.setAdapter(adapter);
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
#Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
#Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment) {
mFragmentList.add(fragment);
}
#Override
public CharSequence getPageTitle(int position) {
return null;
}
}

Related Links

How to deploy android plugin that can be loaded from my application
Display Android Preferences in Different Units
SOCKet Secure (SOCKS) server for Android
Android: NullPointer Exception on recreating the alarm on OS Bootup?
Android with thread shows error
Android Circular Motion of a Device
Android application for Tablet
Android SDK - Preloading a small images gets my application to exceed memory
PhoneGap Back Key Function
Need to Check if a particular location is within the boundaries of the map
Can xml resource files be updated from a server without shipping an app update?
How to write files in hidden mode on SD card in Android
Key alias access issue - Android App Export
How to scale layout in android
How do I layout list items to behave like a table rows?
Where to store sound files in the project and what solution to chose for storing refferences to them

Categories

HOME
asp.net-web-api
turing-machines
jpa
owl-carousel
seo
xbee
parameters
missing-data
sendgrid-api-v3
augeas
x-cart
filechannel
naivebayes
tput
scsi
foreign-keys
boost-icl
windows-xp
simpleitk
r-mice
mongoid6
epsilon
resourcebundle
moses
appirater
ms-access-2003
progress-bar
firebase-analytics
testcomplete
dotspatial
utorrent
reactjs.net
sql-delete
searchkit
jpad
odroid
recurrent-neural-network
gdata
unordered-map
comparison-operators
glm-math
stylecop
facebook-social-plugins
opencmis
x++
getchar
openrasta
reportservice2010
openblas
singleinstance
pair-programming
excel-dna
payload
taocp
file-uri
gcloud-ruby
libav
mobiledoc-kit
sapi
xenomai
ons-api
rubaxa-sortable
toolkit
google-refine
zend-currency
mmwormhole
variadic-templates
nodelist
crowd
wcm
parallel-testing
drupal-nodes
gwt-openlayers
eclipse-kepler
gtm-oauth2
c++builder-xe5
android-icons
cascadingdropdown
idn
joomla3.1
cuda-gdb
database-create
cgimage
agility.js
entity-attribute-value
saxparseexception
massive
updatesourcetrigger
cuda.net
windows-identity
linfu-dynamicproxy

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App