List of usage examples for android.widget RelativeLayout RelativeLayout
public RelativeLayout(Context context)
From source file:xyz.openhh.compat.widget.CompatSwipeRefreshLayout.java
private void init(Context context, AttributeSet attrs) { mPullLayoutHeight = ConvertHelper.dpToPx(context, 300); mPullLayoutLoadingHeight = ConvertHelper.dpToPx(context, 70); if (null != attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CompatSwipeRefreshLayout); mMode = typedArray.getInt(R.styleable.CompatSwipeRefreshLayout_compat_mode, MODE_NORMAL); typedArray.recycle();//from w w w . j a v a2s . c o m } mRefreshLayout = new RelativeLayout(context); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, 0); addView(mRefreshLayout, lp); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); setNestedScrollingEnabled(true); }
From source file:com.wms.opensource.shopfast.fragment.ProductsInCollectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);// www. java2 s . com return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewPreview = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewPreview.setLayoutParams(imageViewParams); imageViewPreview.setVisibility(View.INVISIBLE); imageViewPreview.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(ProductsInCollectionFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewPreview); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading products, display products if they have been saved before. String productsFilePath = StorageUtil.getTempDirectoryPath(getActivity()) + "/" + PersistFileNameProvider.getProductsFileName(collectionID, page); boolean productsFileExists = FileUtil.fileExist(productsFilePath); if (productsFileExists) { loadProductsFromLocalTask = new LoadCachedProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadProductsFromLocalTask.execute(collectionID); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkConnection(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { loadShopifyProductsTask = new LoadProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadShopifyProductsTask.execute(collectionID); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:de.gebatzens.ggvertretungsplan.fragment.RemoteDataFragment.java
public void createButtonWithText(Activity activity, ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(activity); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TextView tv = new TextView(activity); RelativeLayout.LayoutParams tvparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tvparams.addRule(RelativeLayout.ABOVE, R.id.reload_button); tvparams.addRule(RelativeLayout.CENTER_HORIZONTAL); tv.setLayoutParams(tvparams);/* w w w . j a v a 2s.co m*/ tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); tv.setGravity(Gravity.CENTER_HORIZONTAL); r.addView(tv); Button b = new Button(activity); RelativeLayout.LayoutParams bparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); bparams.addRule(RelativeLayout.CENTER_VERTICAL); bparams.addRule(RelativeLayout.CENTER_HORIZONTAL); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); r.addView(b); l.addView(r); }
From source file:at.alladin.rmbt.android.fragments.history.RMBTFilterFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); view = inflater.inflate(R.layout.history_filter, container, false); deviceListView = (LinearLayout) view.findViewById(R.id.deviceList); networkListView = (LinearLayout) view.findViewById(R.id.networkList); final RelativeLayout resultLimitView = (RelativeLayout) view.findViewById(R.id.Limit25Wrapper); limit25CheckBox = (CheckBox) view.findViewById(R.id.Limit25CheckBox); if (activity.getHistoryResultLimit() == 250) limit25CheckBox.setChecked(true); else// w w w . ja v a 2 s . c om limit25CheckBox.setChecked(false); resultLimitView.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (limit25CheckBox.isChecked()) { limit25CheckBox.setChecked(false); activity.setHistoryResultLimit(0); } else { limit25CheckBox.setChecked(true); activity.setHistoryResultLimit(250); } } }); devicesToShow = activity.getHistoryFilterDevicesFilter(); networksToShow = activity.getHistoryFilterNetworksFilter(); if (devicesToShow == null && networksToShow == null) { devicesToShow = new ArrayList<String>(); networksToShow = new ArrayList<String>(); } final float scale = activity.getResources().getDisplayMetrics().density; final int leftRightItem = Helperfunctions.dpToPx(5, scale); // int topBottomItem = Helperfunctions.dpToPx(5, scale); // int leftRightDiv = Helperfunctions.dpToPx(0, scale); // int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); // int topBottomImg = Helperfunctions.dpToPx(1, scale); final String historyDevices[] = activity.getHistoryFilterDevices(); if (historyDevices != null) { for (int i = 0; i < historyDevices.length; i++) { final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); singleItemLayout.setId(i); singleItemLayout.setClickable(true); singleItemLayout.setBackgroundResource(R.drawable.list_selector); singleItemLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight); RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemTitle.setLayoutParams(layout); itemTitle.setGravity(Gravity.LEFT); itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0); itemTitle.setText(historyDevices[i]); singleItemLayout.addView(itemTitle, layout); final CheckBox itemCheck = new CheckBox(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemCheck.setLayoutParams(layout); itemCheck.setGravity(Gravity.RIGHT); itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0); itemCheck.setOnClickListener(null); itemCheck.setClickable(false); itemCheck.setId(i + historyDevices.length); if (devicesToShow.isEmpty() || devicesToShow.contains(historyDevices[i])) itemCheck.setChecked(true); else itemCheck.setChecked(false); singleItemLayout.addView(itemCheck, layout); // layout = new // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // singleItemLayout.setLayoutParams(layout); singleItemLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyDevices.length); if (check.isChecked()) { check.setChecked(false); devicesToShow.remove(historyDevices[v.getId()]); } else { check.setChecked(true); devicesToShow.add(historyDevices[v.getId()]); } } }); deviceListView.addView(singleItemLayout); final View divider = new View(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); deviceListView.addView(divider, layout); } deviceListView.invalidate(); } final String historyNetworks[] = activity.getHistoryFilterNetworks(); if (historyNetworks != null) { for (int i = 0; i < historyNetworks.length; i++) { final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); singleItemLayout.setId(i); singleItemLayout.setClickable(true); singleItemLayout.setBackgroundResource(R.drawable.list_selector); singleItemLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight); RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemTitle.setLayoutParams(layout); itemTitle.setGravity(Gravity.LEFT); itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0); itemTitle.setText(historyNetworks[i]); singleItemLayout.addView(itemTitle, layout); final CheckBox itemCheck = new CheckBox(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemCheck.setLayoutParams(layout); itemCheck.setGravity(Gravity.RIGHT); itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0); itemCheck.setOnClickListener(null); itemCheck.setClickable(false); itemCheck.setId(i + historyNetworks.length); if (networksToShow.isEmpty() || networksToShow.contains(historyNetworks[i])) itemCheck.setChecked(true); else itemCheck.setChecked(false); singleItemLayout.addView(itemCheck, layout); singleItemLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyNetworks.length); if (check.isChecked()) { check.setChecked(false); networksToShow.remove(historyNetworks[v.getId()]); } else { check.setChecked(true); networksToShow.add(historyNetworks[v.getId()]); } System.out.println(networksToShow.toString()); } }); networkListView.addView(singleItemLayout); final View divider = new View(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); networkListView.addView(divider, layout); } networkListView.invalidate(); } /* * // Set option as Multiple Choice. So that user can able to select * more the one option from list deviceListView.setAdapter(new * ArrayAdapter<String>(activity, * android.R.layout.simple_list_item_multiple_choice, historyDevices)); * deviceListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); * * for (int i = 0; i < historyDevices.length; i++) { * //deviceListView.setItemChecked(i, true); } * * deviceListView.setOnItemClickListener(new OnItemClickListener() { * * @Override public void onItemClick(AdapterView<?> l, View v, int * position, long id) { * * } * * }); * * * // Set option as Multiple Choice. So that user can able to select * more the one option from list networkListView.setAdapter(new * ArrayAdapter<String>(activity, * android.R.layout.simple_list_item_multiple_choice, networkDevices)); * networkListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); * * for (int i = 0; i < networkDevices.length; i++) { * networkListView.setItemChecked(i, true); } * * SparseBooleanArray checked = * deviceListView.getCheckedItemPositions(); ArrayList<String> * devicesToShow = new ArrayList<String>(); for(int i = 0; i < * checked.size()+1; i++){ if(checked.get(i)) * devicesToShow.add(historyDevices[i]); } */ return view; }
From source file:com.githang.androidkit.app.IntroActivity.java
/** * //from ww w . j a va 2 s . com */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java
/** * /* ww w . java2s . c o m*/ */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public void createMessage(ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(getActivity()); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); LinearLayout l2 = new LinearLayout(getActivity()); l2.setOrientation(LinearLayout.VERTICAL); RelativeLayout.LayoutParams layoutparams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutparams.addRule(RelativeLayout.CENTER_VERTICAL); l2.setLayoutParams(layoutparams);// w w w . j ava 2 s . c om l2.setGravity(Gravity.CENTER_HORIZONTAL); TextView tv = new TextView(getActivity()); LinearLayout.LayoutParams tvparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tv.setLayoutParams(tvparams); tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); l2.addView(tv); if (button != null) { Button b = new Button(getActivity()); LinearLayout.LayoutParams bparams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bparams.setMargins(toPixels(4), toPixels(0), toPixels(4), toPixels(4)); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); l2.addView(b); } r.addView(l2); l.addView(r); }
From source file:r2b.apps.view.base.BaseAbsListFragment.java
@Override protected void initViews() { absListView = (AbsListView) getView().findViewById(android.R.id.list); emptyView = getEmptyView();/*from w w w. j a v a 2 s .c o m*/ errorView = getErrorView(); loadingView = getLoadingView(); RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_HORIZONTAL); lp.addRule(RelativeLayout.CENTER_VERTICAL); RelativeLayout rl = new RelativeLayout(getActivity()); rl.setLayoutParams(lp); if (emptyView != null) { rl.addView(emptyView); } if (errorView != null) { rl.addView(errorView); } if (loadingView != null) { rl.addView(loadingView); } ViewGroup parent = (ViewGroup) absListView.getParent(); parent.addView(rl); absListView.setEmptyView(rl); showEmptyView(); }
From source file:com.inter.trade.view.slideplayview.AbSlidingPlayView.java
/** * /*from w ww.ja v a 2 s.com*/ * ???View * @param context * @throws */ public void initView(Context context) { this.context = context; layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); pageLineLayoutParams = 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); // mPageLineLayoutParent = new LinearLayout(context); mPageLineLayoutParent.setPadding(0, 5, 0, 5); pageLineLayout = new LinearLayout(context); pageLineLayout.setPadding(15, 1, 15, 1); pageLineLayout.setVisibility(View.INVISIBLE); mPageLineLayoutParent.addView(pageLineLayout, 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(mPageLineLayoutParent, lp2); addView(mRelativeLayout, layoutParamsFW); displayImage = AbFileUtil.getBitmapFormSrc("image/play_display.png"); hideImage = AbFileUtil.getBitmapFormSrc("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:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewData preparedViewData = new ViewData(); int widgetLayout; preparedViewData.openHABWidget = getItem(position); switch (mWidgetLayoutType) { case IconTextControlList: widgetLayout = mWidgetTypeLayoutProvider.getRowLayoutId(preparedViewData.openHABWidget.getType()); break;/*from w w w .java 2 s.com*/ default: widgetLayout = R.layout.openhabwidgetlist_generic_controlless_item; break; } if (convertView == null) { preparedViewData.widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); try { vi.inflate(widgetLayout, preparedViewData.widgetView, true); } catch (Exception ex) { Log.w("OpenHABWidgetArrayAdapt", String.format("'%s' of type '%s' cannot get inflated in widget list", preparedViewData.openHABWidget, preparedViewData.openHABWidget.getType()), ex); } } else { preparedViewData.widgetView = (RelativeLayout) convertView; } processIconImage(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.labelTextView = getLabelTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.valueTextView = getValueTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); View widgetView = null; if (mWidgetLayoutType == WidgetLayoutType.IconTextList) { widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); return widgetView; } switch (preparedViewData.openHABWidget.getType()) { case Frame: widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); break; case Group: widgetView = new OpenHABGroupWidget(this, preparedViewData).getWidget(); break; case SelectionSwitch: widgetView = new OpenHABSelectionSwitchWidget(this, preparedViewData).getWidget(); break; case Switch: widgetView = new OpenHABSwitchWidget(this, preparedViewData).getWidget(); break; case Color: widgetView = new OpenHABColorWidget(this, preparedViewData).getWidget(); break; case RollerShutter: widgetView = new OpenHABRollerShutterWidget(this, preparedViewData).getWidget(); break; case ItemText: case SitemapText: widgetView = new OpenHABTextWidget(this, preparedViewData).getWidget(); break; case Slider: widgetView = new OpenHABSliderWidget(this, preparedViewData).getWidget(); break; case Image: widgetView = new OpenHABImageWidget(refreshImageList, this, preparedViewData).getWidget(); break; case Chart: int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); widgetView = new OpenHABChartWidget(screenWidth, refreshImageList, this, preparedViewData).getWidget(); break; case Video: widgetView = new OpenHABVideoWidget(this.getContext(), videoWidgetList, this, preparedViewData) .getWidget(); break; case Web: widgetView = new OpenHABWebWidget(this, preparedViewData).getWidget(); break; case Selection: widgetView = new OpenHABSelectionWidget(this.getContext(), this, preparedViewData).getWidget(); break; case Setpoint: widgetView = new OpenHABSetpointWidget(this.getContext(), this, preparedViewData).getWidget(); break; default: if (preparedViewData.labelTextView != null) preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1/* || !mWidgetLayoutType.equals(WidgetLayoutType.IconTextList)*/) { if (getItem(position + 1).getType() == OpenHABWidgetType.Frame) { dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets } else { dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others } } else { // last widget in the list, hide divider dividerLayout.setVisibility(View.GONE); } } return widgetView; }