سؤال

I need to add more than two views to my viewSwitcher. I tried but I get following error log:

Can't add more than 2 views to a viewSwitcher

I would like to know if I can fix this problem by any property of the ViewSwitcher even if I manually add more views from my Java class.

Thanks!

هل كانت مفيدة؟

المحلول

By using ViewSwitcher, this is not possible.

The Android documentation states:

Class Overview

ViewAnimator that switches between two views, and has a factory from which these views are created. You can either use the factory to create the views, or add them yourself. A ViewSwitcher can only have two child views, of which only one is shown at a time.

نصائح أخرى

On a side note, you can use ViewFlipper, which can contain more than one view

ViewPager is also a good alternative. You can switch between multiple views by swiping.

Here on this link you can find detailed description:

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top