简体   繁体   中英

android viewpager in popupwindow

How can i place a swipeable ViewPager with three tabs inside a PopupWindow ?
I'm totally curious about how to do that! The popup window is opened in a custom View .

currently i have only the popupwindow, which works excellent:

LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popup_view = li.inflate(R.layout.popup_view, null);

final PopupWindow popup = new PopupWindow(context);
popup.setWidth(ViewGroup.LayoutParams.FILL_PARENT);
popup.setHeight(ViewGroup.LayoutParams.FILL_PARENT);

popup.setTouchable(true);
popup.setFocusable(true);

popup.setContentView(popup_view);
popup.showAtLocation(this, Gravity.NO_GRAVITY, 0, 0);

the popup_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- here i want to have the ViewPager with 3 tabs -->

so i have three more layouts ( tab_one.xml tab_two.xml and tab_three.xml ) in which are for now only some test text.

You can implement this using fragments. Create a FragmentActivity which calls a DialogFragment to display the popup window. In it's view, you could define the ViewPager. Have a look at the following answer https://stackoverflow.com/a/19552298/3030934

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM