Tag: android-viewpager

How to handle back button using view pager?

I am having two fragments Frag A and Frag B which are rendered using view pager . If user has swiped from A to B then presses back button(when in B) then user should go to A instead of coming out of view pager . How can we achieve this ? Adding transaction to backstack […]

ViewPager in android is taking full screen?

In my xml file I have a Linear layout that has a ViewPager for showing images and another Linear layout that contains previous and Next buttons for selecting images.My xml looks like this: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” > <android.support.v4.view.ViewPager android:id=”@+id/pager” android:layout_width=”fill_parent” android:layout_height=”wrap_content” /> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:gravity=”center” android:orientation=”horizontal” > <Button android:id=”@+id/goto_first” android:layout_width=”wrap_content” […]

how to get current position in FragmentPagerAdapter?

I have an adapter that extends FragmentPagerAdapter and takes advantage of the ICS style actionBar. This actionbar has actions that take input from the currently selected page. Specifically, I have a screenshot icon in the actionbar that takes the url of the current page and displays any screenshots from that url. However, I dont know […]

VideoView on Viewpager, stopping video when switching page

I have a viewpager with different fragments, one of these has a videoview in it. If I switch page when the video is playing then it remaings playing even when I’m on a different page. I tried implementing an OnPageChangeListener for the ViewPager like this: viewpager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { if(position!=mAdapter.getCount()-1){ […]

How to auto slide android View Pager

Can a View Pager be made to auto slide or autopage. I have my viewpager set up to use the adapter like the below and it works fine:- @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gridslide); ImagePagerAdapter mAdapter = new ImagePagerAdapter( getSupportFragmentManager(),4); ViewPager mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter); } And the adapter is like below:- […]

Left-right arrow indicators over a ViewPager

I want to show left and right arrows over my ViewPager, to indicate swiping. I added two ImageButtons over the ViewPager-element but those areas then block the ViewPager from triggering the “swiping”. I also want presses on those arrows to trigger the fragment to change accordingly. In short: The ImageButtons should not interfere with swiping […]

is there a way to load a default image in picasso

i cannot load an image in picasso from my drawable due to resons known only to picasso, so whever picasso fails to load i want to load a default image please help @Override public Object instantiateItem(ViewGroup container, final int position) { final Context context =getApplicationContext(); final ImageView imageView = new ImageView(getApplicationContext()); int padding = context.getResources().getDimensionPixelSize( […]

Can't close NavigationDrawer with right-to-left swipe

I have been trying to fix the problem I’ve got, which is that I’m unable to close the NavigationDrawer by swiping from right-to-left, without success. Opening it by swiping from the left edge of the screen to the right is working as it should. I’m currently just trying to merge the NavigationDrawer sample and the […]

IllegalArgumentException: radius must be > 0

I’m designing a bar graph and a pie chart in a view pager using AChartEngine library. When I scroll from bar graph to pie chart, application crashes. The crash report is as following. FATAL EXCEPTION: main java.lang.IllegalArgumentException: radius must be > 0 at android.graphics.RadialGradient.<init>(RadialGradient.java:58) at org.achartengine.chart.PieChart.draw(PieChart.java:112) at org.achartengine.GraphicalView.onDraw(GraphicalView.java:168) at android.view.View.draw(View.java:11120) at android.view.ViewGroup.drawChild(ViewGroup.java:2901) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2503) at […]

CoordinatorLayout inside another CoordinatorLayout

CorodinatorLayout inside another CoordinatorLayout such that scrolling the child-view should also scroll the Parent CoordinatorLayout. I have a coordinatorLayout with ViewPager that contains different Fragment such that on Scroll will hide the tabLayout I have another coordinatorLayout that has a viewPager. This fragment is inflated in ViewPager of parent fragment(parent Coordinator layout). The problem is […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.