I use the following code, MAX - 2 pages. By default, the position is 0 and adds a new page to the right. I inflate two layout files.
How can I show page1 when the application starts and add a new page to the left? Thank.
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <android.support.v4.view.ViewPager android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pagerView" /> </LinearLayout>
Java code
public class MyPagerActivity extends Activity { private Context context; private int pageNumber; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); context = this; ViewPager pagerView = (ViewPager)findViewById(R.id.pagerView); pagerView.setAdapter(new AwesomePagerAdapter()); } private class AwesomePagerAdapter extends PagerAdapter{ @Override public void destroyItem(View collection, int position, Object view) { ((ViewPager) collection).removeView((View)view); } @Override public void finishUpdate(View arg0) {
android animation android-viewpager swipe
dcanh121 Sep 13 2018-11-11T00: 00Z
source share