List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java
@Override public View getBody(final AppCompatActivity activity, final Integer textColor, final Float textSize, final boolean showLinkButtons) { final LinearLayout subjectLayout = new LinearLayout(activity); subjectLayout.setOrientation(LinearLayout.VERTICAL); final TextView subjectText = new TextView(activity); subjectText.setText(StringEscapeUtils.unescapeHtml4(src.subject != null ? src.subject : "(no subject)")); subjectText.setTextColor(textColor); subjectText.setTextSize(textSize);/*w w w .ja v a 2 s .c om*/ subjectText.setTypeface(null, Typeface.BOLD); subjectLayout.addView(subjectText); subjectLayout.addView(body.buildView(activity, textColor, textSize, showLinkButtons)); return subjectLayout; }
From source file:org.odk.collect.android.views.ODKView.java
public ODKView(Context context, final FormEntryPrompt[] questionPrompts, FormEntryCaption[] groups, boolean advancingPage) { super(context); inflate(getContext(), R.layout.nested_scroll_view, this); // keep in an xml file to enable the vertical scrollbar widgets = new ArrayList<>(); view = new LinearLayout(getContext()); view.setOrientation(LinearLayout.VERTICAL); view.setGravity(Gravity.TOP);/*w w w . j ava 2 s . co m*/ view.setPadding(0, 7, 0, 0); layout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layout.setMargins(10, 0, 10, 0); // display which group you are in as well as the question addGroupText(groups); // when the grouped fields are populated by an external app, this will get true. boolean readOnlyOverride = false; // get the group we are showing -- it will be the last of the groups in the groups list if (groups != null && groups.length > 0) { final FormEntryCaption c = groups[groups.length - 1]; final String intentString = c.getFormElement().getAdditionalAttribute(null, "intent"); if (intentString != null && intentString.length() != 0) { readOnlyOverride = true; final String buttonText; final String errorString; String v = c.getSpecialFormQuestionText("buttonText"); buttonText = (v != null) ? v : context.getString(R.string.launch_app); v = c.getSpecialFormQuestionText("noAppErrorString"); errorString = (v != null) ? v : context.getString(R.string.no_app); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5); // set button formatting Button launchIntentButton = new Button(getContext()); launchIntentButton.setId(ViewIds.generateViewId()); launchIntentButton.setText(buttonText); launchIntentButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Collect.getQuestionFontsize() + 2); launchIntentButton.setPadding(20, 20, 20, 20); launchIntentButton.setLayoutParams(params); launchIntentButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String intentName = ExternalAppsUtils.extractIntentName(intentString); Map<String, String> parameters = ExternalAppsUtils.extractParameters(intentString); Intent i = new Intent(intentName); try { ExternalAppsUtils.populateParameters(i, parameters, c.getIndex().getReference()); for (FormEntryPrompt p : questionPrompts) { IFormElement formElement = p.getFormElement(); if (formElement instanceof QuestionDef) { TreeReference reference = (TreeReference) formElement.getBind().getReference(); IAnswerData answerValue = p.getAnswerValue(); Object value = answerValue == null ? null : answerValue.getValue(); switch (p.getDataType()) { case Constants.DATATYPE_TEXT: case Constants.DATATYPE_INTEGER: case Constants.DATATYPE_DECIMAL: i.putExtra(reference.getNameLast(), (Serializable) value); break; } } } ((Activity) getContext()).startActivityForResult(i, RequestCodes.EX_GROUP_CAPTURE); } catch (ExternalParamsException e) { Timber.e(e, "ExternalParamsException"); ToastUtils.showShortToast(e.getMessage()); } catch (ActivityNotFoundException e) { Timber.d(e, "ActivityNotFoundExcept"); ToastUtils.showShortToast(errorString); } } }); View divider = new View(getContext()); divider.setBackgroundResource(new ThemeUtils(getContext()).getDivider()); divider.setMinimumHeight(3); view.addView(divider); view.addView(launchIntentButton, layout); } } boolean first = true; for (FormEntryPrompt p : questionPrompts) { if (!first) { View divider = new View(getContext()); divider.setBackgroundResource(new ThemeUtils(getContext()).getDivider()); divider.setMinimumHeight(3); view.addView(divider); } else { first = false; } // if question or answer type is not supported, use text widget QuestionWidget qw = WidgetFactory.createWidgetFromPrompt(p, getContext(), readOnlyOverride); qw.setLongClickable(true); qw.setOnLongClickListener(this); qw.setId(ViewIds.generateViewId()); widgets.add(qw); view.addView(qw, layout); } ((NestedScrollView) findViewById(R.id.odk_view_container)).addView(view); // see if there is an autoplay option. // Only execute it during forward swipes through the form if (advancingPage && widgets.size() == 1) { final String playOption = widgets.get(0).getFormEntryPrompt().getFormElement() .getAdditionalAttribute(null, "autoplay"); if (playOption != null) { Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (playOption.equalsIgnoreCase("audio")) { widgets.get(0).playAudio(); } else if (playOption.equalsIgnoreCase("video")) { widgets.get(0).playVideo(); } } }, 150); } } }
From source file:de.vanita5.twittnuker.fragment.support.BasePullToRefreshListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to * be shown when the list is empty./* www .j ava 2 s . c o m*/ * <p> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in * your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final RefreshNowListView lv = new RefreshNowListView(getActivity()); lv.setId(android.R.id.list); lv.setOverScrollMode(View.OVER_SCROLL_NEVER); lv.setDrawSelectorOnTop(false); lv.setOnRefreshListener(this); lv.setConfig(ThemeUtils.buildRefreshNowConfig(context)); lv.setOnTouchListener(this); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final RefreshNowProgressIndicator indicator = new RefreshNowProgressIndicator(context); indicator.setConfig(ThemeUtils.buildRefreshIndicatorConfig(context)); final int indicatorHeight = Math.round(3 * getResources().getDisplayMetrics().density); lframe.addView(indicator, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, indicatorHeight, Gravity.TOP)); lv.setRefreshIndicatorView(indicator); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:hotstu.github.bdzviewer.ui.CustomListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the * returned view hierarchy <em>must</em> have a ListView whose id * is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} * that is to be shown when the list is empty. * //from www . j a v a 2s .c o m * <p>If you are overriding this method with your own custom content, * consider including the standard layout {@link android.R.layout#list_content} * in your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only * way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
From source file:com.ab.view.sliding.AbSlidingPlayView.java
/** * ???View./*w ww . j a v a 2 s. c o m*/ * * @param context the context */ public void initView(Context context) { this.context = context; navLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); RelativeLayout mRelativeLayout = new RelativeLayout(context); mViewPager = new AbInnerViewPager(context); //ViewPager,fragmentsetId()id mViewPager.setId(1985); // mNavLayoutParent = new LinearLayout(context); mNavLayoutParent.setPadding(0, 5, 0, 5); navLinearLayout = new LinearLayout(context); navLinearLayout.setPadding(15, 1, 15, 1); navLinearLayout.setVisibility(View.INVISIBLE); mNavLayoutParent.addView(navLinearLayout, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mRelativeLayout.addView(mViewPager, lp1); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mRelativeLayout.addView(mNavLayoutParent, lp2); addView(mRelativeLayout, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); displayImage = AbFileUtil.getBitmapFromSrc("image/play_display.png"); hideImage = AbFileUtil.getBitmapFromSrc("image/play_hide.png"); mListViews = new ArrayList<View>(); mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews); mViewPager.setAdapter(mAbViewPagerAdapter); mViewPager.setFadingEdgeLength(0); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { makesurePosition(); onPageSelectedCallBack(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageScrolledCallBack(position); } }); }
From source file:br.org.funcate.dynamicforms.views.GSketchView.java
/** * @param noteId the id of the note this image belows to. * @param fragmentDetail the fragment detail to use. * @param attrs attributes. * @param requestCode the code for starting the activity with result. * @param parentView parent// w w w . j av a 2s . co m * @param label label * @param value value * @param constraintDescription constraints */ public GSketchView(final long noteId, final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode, LinearLayout parentView, String label, String value, String constraintDescription) { super(fragmentDetail.getActivity(), attrs); this.noteId = noteId; _value = value; final FragmentActivity activity = fragmentDetail.getActivity(); LinearLayout textLayout = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 10, 10, 10); textLayout.setLayoutParams(layoutParams); textLayout.setOrientation(LinearLayout.VERTICAL); parentView.addView(textLayout); TextView textView = new TextView(activity); textView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); textView.setPadding(2, 2, 2, 2); textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription); textView.setTextColor(activity.getResources().getColor(R.color.formcolor)); textLayout.addView(textView); final Button button = new Button(activity); button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); button.setPadding(15, 5, 15, 5); button.setText(R.string.draw_sketch); textLayout.addView(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); double[] gpsLocation = PositionUtilities.getGpsLocationFromPreferences(preferences); Date currentDate = new Date(); String sketchImageName = ImageUtilities.getSketchImageName(currentDate); File tempDir = ResourcesManager.getInstance(getContext()).getTempDir(); File sketchFile = new File(tempDir, sketchImageName); /* * open markers for new sketch */ MarkersUtilities.launch(fragmentDetail, sketchFile, gpsLocation, requestCode); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }); ScrollView scrollView = new ScrollView(activity); ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, 150); scrollView.setLayoutParams(scrollLayoutParams); parentView.addView(scrollView); imageLayout = new LinearLayout(activity); LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); imageLayout.setLayoutParams(imageLayoutParams); // imageLayout.setMinimumHeight(200); imageLayout.setOrientation(LinearLayout.HORIZONTAL); scrollView.addView(imageLayout); // scrollView.setFillViewport(true); try { refresh(activity); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(this.getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
From source file:com.ab.view.sliding.AbSlidingTabView.java
/** * Instantiates a new ab sliding tab view. * * @param context the context/* ww w. j ava2s . co m*/ * @param attrs the attrs */ public AbSlidingTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabScrollView = new HorizontalScrollView(context); mTabScrollView.setHorizontalScrollBarEnabled(false); mTabScrollView.setSmoothScrollingEnabled(true); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //mTabLayout mTabScrollView.addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.FILL_PARENT)); this.addView(mTabScrollView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbSlidingTabView.class, "AbSlidingTabView?context,FragmentActivity"); } FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.tablet.MapMultiPaneActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE); LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer); spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); spacerView.setGravity(landscape ? Gravity.END : Gravity.BOTTOM); View popupView = findViewById(R.id.map_detail_popup); LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams(); popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT; popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0; popupView.setLayoutParams(popupLayoutParams); popupView.requestLayout();/*from w w w . java 2 s.c om*/ updateMapPadding(); }
From source file:com.ab.view.sliding.AbBottomTabView.java
/** * Instantiates a new ab bottom tab view. * * @param context the context/* w ww.j a va 2 s. co m*/ * @param attrs the attrs */ public AbBottomTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); //Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView.class, "AbSlidingTabView?context,FragmentActivity"); } FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.dreamchen.useful.mouserace.view.sliding.AbSlidingSmoothFixTabView.java
/** * Instantiates a new ab sliding smooth fix tab view. * * @param context the context/* w w w . ja v a 2 s .com*/ * @param attrs the attrs */ public AbSlidingSmoothFixTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabLayout, layoutParamsFW); //? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbSlidingSmoothFixTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getSupportFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }