Call other layout xml in JazzyViewPager and use it.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.