List of usage examples for android.view View setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.lgmshare.component.widget.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (tabBackgroundResId > 0) { v.setBackgroundResource(tabBackgroundResId); }//from w ww . j a va 2 s .c o m if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } } }
From source file:com.messi.appshelper.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(!tabSwitch ? tabBackgroundResId : transparentColorId); if (v instanceof TextView) { TextView tab = (TextView) v; v.setLayoutParams(expandedTabLayoutParams); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabSwitch && i != 0 ? tabDeactivateTextColor : tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }/*from w w w . j a v a 2 s.co m*/ } } else if (v instanceof ImageButton) { ImageButton tab = (ImageButton) v; tab.setSelected(tabSwitch && i == 0 ? true : false); } } }
From source file:littlechi.dyc.com.littlechi.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }/*w ww .j a v a 2 s . co m*/ } if (i == currentPosition) { tab.setTextColor(selectedTabTextColor); } } } }
From source file:com.stepstone.stepper.StepperLayout.java
private void setBackgroundIfPresent(@DrawableRes int backgroundRes, View view) { if (backgroundRes != 0) { view.setBackgroundResource(backgroundRes); }// ww w. j a v a2s . co m }
From source file:com.astuetz.PagerSlidingTriangleStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); //#####??###### //?item ?? tab.setTextColor(pager.getCurrentItem() == i ? tabSelectedTextColor : tabNormalTextColor); //################### // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w ww . ja v a 2 s. c om } } } }
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 ww.j a va2 s . c o 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:com.hadis.hadispagerslidingtabstrip.tabutil.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w w w.ja v a2 s. co m } // by Hadis if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize); } } } }
From source file:com.hdezninirola.fantasywithdrawer.custom_views.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(!tabSwitch ? tabBackgroundResId : transparentColorId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabSwitch ? tabDeactivateTextColor : tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }/*from ww w . j a v a2 s . c o m*/ } } else if (v instanceof ImageButton) { ImageButton tab = (ImageButton) v; tab.setSelected(tabSwitch ? true : false); } } }
From source file:com.szhr.noname.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); //!!! tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case // is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }/*from w ww . j a v a 2 s .co m*/ } } } }
From source file:com.carinsurance.pagerslidingtabstrip.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // tab.setTextColor(Color.parseColor("#00a2d0")); // setAllCaps() is only available from API 14, so the upper case // is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from w ww . j av a 2 s . c om } } } }