Call other layout xml in JazzyViewPager and use it.
Open Source Address: https://github.com/jfeinstein10/JazzyViewPager
The online example is created using a TextView directly. But in fact, it is impossible to only use this control.
The following is my implementation method. If you have a better method, I am sorry. Thank you ~~~
In the custom
MainAdapter extends PagerAdapter
+ Public Object instantiateItem (ViewGroup container, final int position) {some code in the method is implemented as follows:
View currView = null; LayoutInflater factory = LayoutInflater. from (context); currView = factory. inflate (getLayoutId (), null); // obtain the control content and set the click to listen to final RelativeLayout btnDebug = (RelativeLayout) currView. findViewById (R. id. btnDebug); Log. d ("MainAdapter", "Button is null? "+ (BtnDebug = null); if (btnDebug! = Null) btnDebug. setOnClickListener (new View. onClickListener () {@ Override public void onClick (View v) {Log. d ("DEBUG", "click me. ") ;}}); container. addView (currView, ViewGroup. layoutParams. MATCH_PARENT, ViewGroup. layoutParams. MATCH_PARENT); jazzyPager. setObjectForPosition (currView, position); return currView;
That is, you need to load the layout XML in layout through code. I wonder if there is any other way.