Problems with ViewPager and LayoutInflater

Source: Internet
Author: User

The problem is as follows:
1. How should I configure ViewPager? (Imitation function boot page)

* A layout is required. The layout contains android. support. v4.view. ViewPager, and several imageviews that represent vertices (using XML to implement drawable, so as to switch between vertices of different colors ).

* The User-Defined adapter must inherit the PagerAdapter and implement the getCount, isViewFromObject, destroyItem, and instantiateItem methods. The imported List <View> pageViews

* Define and obtain the List <View> In the Activity (install the page view, each page is an XML layout, which needs to be obtained by LayoutInflater), List <ImageView> (install the dot view ), obtain ViewPager, instantiate Adapter, and viewPager. setAdapter, viewPager. setOnPageChangeListener (this function needs to change the dot color in onPageSelected)

 


2. LayoutInflater clearly does not use errors. XML is correct. Why does it still report android. view. InflateException: Binary XML file line #8: Error inflating class errors?

The error is reported here:


[Java]
Private List <View> getViews (){
LayoutInflater inflater = this. getLayoutInflater (); // reflection
List <View> views = new ArrayList <View> ();
View view1 = inflater. inflate (R. layout. intro_page_one, null); // an error is returned here.
Views. add (view1 );
View view2 = inflater. inflate (R. layout. intro_page_two, null );
Views. add (view2 );

Return views;
}

Private List <View> getViews (){
LayoutInflater inflater = this. getLayoutInflater (); // reflection
List <View> views = new ArrayList <View> ();
View view1 = inflater. inflate (R. layout. intro_page_one, null); // an error is returned here.
Views. add (view1 );
View view2 = inflater. inflate (R. layout. intro_page_two, null );
Views. add (view2 );

Return views;
} Three methods are used to obtain LayoutInflater. The result is the same. # three methods are used to obtain LayoutInflater #


Actually, OutOfMemoryError is reported later. How can this problem be solved! I changed several images (the original images are 700 K, for 30 K), and the results are displayed normally !!!!

This reflection is called because the Layout to be obtained is not the Layout in setContentView.

 


3. How to Implement the first installation of the APP, go to the welcome page, pause for 3 seconds, go to the boot page, and click OK to go to the APP;

Then, start the APP and go to the welcome page. Instead of the boot page, go directly to the APP;

Click the Help button in the APP. The APP will be restarted to go to the welcome page, go to the boot page, and go to the APP?

 

Related Article

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.