android-viewpager

instantiate all items in view pager android

房东的猫 提交于 2019-12-21 07:18:08
问题 I have an activity with a view pager and three pages to display. When ever the activity loads, only the first two pages are instantiated i.e instantiateitem in the pageradapter class is called only for position 0 and 1. Is there a way to instantiate all the three pages? 回答1: Try setOffScreenPageLimit(2). By default only one page to the left and to the right are instantiated. By setting to 2 it should instantiate your 3 pages. 来源: https://stackoverflow.com/questions/10046484/instantiate-all

CoordinatorLayout + AppbarLayout + Viewpager not resize child layout

冷暖自知 提交于 2019-12-21 06:57:47
问题 I have a problem using CoordinatorLayout in conjunction with ViewPager and the ViewPager: the layout does not resize correctly. Supose that the height solved includes tabs height. So when I scroll to bottom i see this: main layout code: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@

ViewPager with ImageView gives “java.lang.OutOfMemoryError: bitmap size exceeds VM budget”

自闭症网瘾萝莉.ら 提交于 2019-12-21 06:45:17
问题 I made a ViewPager to display images. When I advance some pages I get an java.lang.OutOfMemoryError: bitmap size exceeds VM budget error. There are more questions about this issue but I did not find the solution ( BitMap.Recycle , System.gc() etc). If you have a suggestion or solution please let me know! The PNG's are 628KB, 478KB, 587KB, 132KB, 139KB, 149KB, 585KB (crash). If you have an other solution (scroll images like pages) for me let met know! My code: package nl.ipear.vngmagazine;

Using a ViewPager over a CameraPreview

浪尽此生 提交于 2019-12-21 06:25:24
问题 I've been trying to create a Camera Preview that displays a View Pager with several transparent images over the preview. But, I'm getting this error: 05-10 03:31:23.614: E/AndroidRuntime(674): FATAL EXCEPTION: main 05-10 03:31:23.614: E/AndroidRuntime(674): java.lang.NullPointerException 05-10 03:31:23.614: E/AndroidRuntime(674): at com.android.gs1.MainActivity$CameraPreview.surfaceCreated(MainActivity.java:102) 05-10 03:31:23.614: E/AndroidRuntime(674): at android.view.SurfaceView

How to remove pages in Android ViewPager?

南笙酒味 提交于 2019-12-21 05:56:27
问题 I'm trying to add/remove dynamically fragments in a ViewPager following a button click, but if I remove the fragment (a form) by clicking on back button, and add the fragment again, the form has kept its data (EditText not empty). Here is my adapter : package com.thomas.playlists.viewPager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import java.util.ArrayList; public class ViewPagerAdapter extends

Android, How to mix ActionBar.Tab + View Pager + ListFragment

ぐ巨炮叔叔 提交于 2019-12-21 05:27:06
问题 I've been trying to test how to mix all these things together and I'm having problems!! I just want an app with three tabs using the ActionBar.Tab. For example, this tabs can be movies genres Action, Adventure and Animation, the user can swipe through the tabs, so it will use the ViewPager and each tab will show a list of movies of that genre. There's no need to have three different fragments classes because all tabs will be the same format a simple list. And I'm having problems because when

Android create ViewPager programmatically

ぐ巨炮叔叔 提交于 2019-12-21 05:16:05
问题 I create a view pager programmatically and I add this view pager into layout but it doesn't run. ViewPager viewPager = new ViewPager(this); viewPager.setAdapter(new MyPagerAdapter()); addView(viewPager); The view pager is not working; but when I use it from XML it works fine. I want to use it dynamically. 回答1: Please, post also the code of 'addView' method. Right now I would only suggest adding some layout attributes like width and height to your viewPager. UPDATE: Ok, I just encountered that

How to replace Fragment inside ViewPager, using PagerAdapter?

北城余情 提交于 2019-12-21 04:16:20
问题 My problem I am using a ViewPager to display fragments inside a FragmentActivity . ViewPager gets fragments from the attached FragmentPagerAdapter . mViewPager = (ViewPager) findViewById(R.id.view_pager); mAdapter = new HomePagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mAdapter); Suppose ViewPager has 3 fragments to display: Fragment1 , Fragment2 , Fragment3 . Fragment1 is a grid fragment and displays a grid. Fragment2 and Fragment3 have their own content to display. When

View pager indicator Jake Wharton

南笙酒味 提交于 2019-12-21 04:14:33
问题 I m using Jake Wharton's example for showing viewpager indicator. www.viewpagerindicator.com I am using snap circle indicator. can anyone please tell me how to increase the width between the circles? What parameter should be changed? 回答1: We need to increase the "threeRadius" parameter to higher value. Thanks. 回答2: You can find all parameter in file res/values/vpi_attrs.xml. The style associated of CirclePageIndicator specified : <!-- Radius of the circles. This is also the spacing between

How to use Actionbar items with Viewpager + Fragments

会有一股神秘感。 提交于 2019-12-21 04:13:00
问题 Im trying to figure out how to implement Actionbar items based on the Fragment that is being loaded inside my viewpager. My code is below and im just trying to figure out the best practice for working with ABS + ViewPager + Fragments. MainActivity public class MainActivity extends SherlockFragmentActivity { private ViewPager mPager; private TitlePageIndicator mIndicator; private MainPagerAdapter mAdapter; private List<Fragment> mFragments; private static final String FRAGMENT1 = Fragment1