本文整理汇总了Java中android.view.View.setBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:Java View.setBackgroundResource方法的具体用法?Java View.setBackgroundResource怎么用?Java View.setBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setBackgroundResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildLoading
import android.view.View; //导入方法依赖的package包/类
protected BuildBean buildLoading(BuildBean bean) {
Dialog dialog = new Dialog(bean.mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bean.dialog = dialog;
View root;
if (bean.isVertical) {
root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
} else {
root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
}
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
tvMsg.setTextColor(Color.WHITE);
}
bean.dialog.setContentView(root);
return bean;
}
示例2: getView
import android.view.View; //导入方法依赖的package包/类
@Override
public View getView(int position, View v, ViewGroup parent) {
try {
if (v == null) v = getLayoutInflater(null).inflate(R.layout.listeelem_2linjer, parent, false);
AQuery aq = new AQuery(v);
Programserie ps = liste.get(position);
aq.id(R.id.linje1).text(ps.titel).typeface(App.skrift_gibson_fed).textColor(Color.BLACK);
int n = ps.antalUdsendelser;
String txt = n==0 ? "" : n==1 ? n + " udsendelse" : n + " udsendelser";
aq.id(R.id.linje2).text(txt).typeface(App.skrift_gibson);
aq.id(R.id.stiplet_linje).visibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
v.setBackgroundResource(0);
} catch (Exception e) {
Log.rapporterFejl(e);
}
return v;
}
示例3: addIndicator
import android.view.View; //导入方法依赖的package包/类
/**
* 添加底部Indicator点
*/
private void addIndicator() {
llIndicator.removeAllViews();
indicatorViews.clear();
for (int i = 0; i < carouselPageAdapter.getCount(); i++) {
View indicatorView = new View(context);
indicatorView.setBackgroundResource(i == 0 ? indicatorSelected : indicatorUnselected);
llIndicator.addView(indicatorView);
LinearLayout.MarginLayoutParams params = (LinearLayout.MarginLayoutParams) indicatorView.getLayoutParams();
if (i == 0 && indicatorSelectedWidth > 0 && indicatorSelectedHeight > 0) {
params.width = indicatorSelectedWidth;
params.height = indicatorSelectedHeight;
} else if (i > 0 && indicatorUnSelectedWidth > 0 && indicatorUnSelectedHeight > 0) {
params.width = indicatorUnSelectedWidth;
params.height = indicatorUnSelectedHeight;
} else {
params.width = indicatorWidth;
params.height = indicatorHeight;
}
params.leftMargin = indicatorPadding / 2;
params.rightMargin = indicatorPadding / 2;
indicatorView.setLayoutParams(params);
indicatorViews.add(indicatorView);
}
}
示例4: buildMdLoadingVertical
import android.view.View; //导入方法依赖的package包/类
protected BuildBean buildMdLoadingVertical(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
tvMsg.setTextColor(Color.WHITE);
}
builder.setView(root);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
return bean;
}
示例5: buildLoadingHorizontal
import android.view.View; //导入方法依赖的package包/类
protected BuildBean buildLoadingHorizontal(BuildBean bean) {
Dialog dialog = new Dialog(bean.mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bean.dialog = dialog;
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
bean.dialog.setContentView(root);
return bean;
}
示例6: buildMdLoadingHorizontal
import android.view.View; //导入方法依赖的package包/类
protected BuildBean buildMdLoadingHorizontal(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
builder.setView(root);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
return bean;
}
示例7: onPageSelected
import android.view.View; //导入方法依赖的package包/类
@Override public void onPageSelected(int position) {
if (mViewpager.getAdapter() == null || mViewpager.getAdapter().getCount() <= 0) {
return;
}
if (mAnimatorIn.isRunning()) {
mAnimatorIn.end();
mAnimatorIn.cancel();
}
if (mAnimatorOut.isRunning()) {
mAnimatorOut.end();
mAnimatorOut.cancel();
}
View currentIndicator;
if (mLastPosition >= 0 && (currentIndicator = getChildAt(mLastPosition)) != null) {
currentIndicator.setBackgroundResource(mIndicatorUnselectedBackgroundResId);
mAnimatorIn.setTarget(currentIndicator);
mAnimatorIn.start();
}
View selectedIndicator = getChildAt(position);
if (selectedIndicator != null) {
selectedIndicator.setBackgroundResource(mIndicatorBackgroundResId);
mAnimatorOut.setTarget(selectedIndicator);
mAnimatorOut.start();
}
mLastPosition = position;
}
示例8: background
import android.view.View; //导入方法依赖的package包/类
private void background(View view, Object object) {
if (object.getClass().equals(Integer.class)) {
view.setBackgroundResource(Integer.parseInt(object.toString()));
} else if (object.getClass().equals(Drawable.class)) {
view.setBackgroundDrawable((Drawable) object);
} else {
throw new IllegalStateException("The parameter method need be Integer, Drawable");
}
}
示例9: init
import android.view.View; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(R.attr.colorAccent, outValue, true);
tintColor = ContextCompat.getColor(context, outValue.resourceId);
// Create morph view
morphView = new View(getContext());
morphView.setBackgroundResource(R.drawable.previewseekbar_morph);
// Create frame view for the circular reveal
frameView = new View(getContext());
delegate = new PreviewDelegate(this);
}
示例10: setCurrentItem
import android.view.View; //导入方法依赖的package包/类
public void setCurrentItem(int item) {
if (this.mViewPager == null) {
throw new IllegalStateException("ViewPager has not been bound.");
}
this.mSelectedTabIndex = item;
if (this.mSelectedTabIndex != item) {
this.mViewPager.setCurrentItem(item);
}
int tabCount = this.mTabLayout.getChildCount();
for (int i = 0; i < tabCount; i++) {
boolean isSelected;
View child = this.mTabLayout.getChildAt(i);
if (i == item) {
isSelected = true;
} else {
isSelected = false;
}
child.setSelected(isSelected);
if (isSelected) {
animateToTab(item);
((TabView) child).setTextColor(this.mContext.getResources().getColor(R.color.letv_color_ffef534e));
child.setBackgroundResource(R.drawable.tab_indicator_bg);
} else {
((TabView) child).setTextColor(this.mContext.getResources().getColor(R.color.letv_color_ff444444));
child.setBackgroundDrawable(null);
}
if (i == 0 && (child instanceof FrameLayout)) {
((FrameLayout) child).getChildAt(0).setBackgroundDrawable(null);
}
}
}
示例11: updateTabStyles
import android.view.View; //导入方法依赖的package包/类
private void updateTabStyles() {
for (int i = 0; i < this.tabCount; i++) {
View v = this.tabsContainer.getChildAt(i);
v.setBackgroundResource(this.tabBackgroundResId);
if ((v instanceof FrameLayout) && ((FrameLayout) v).getChildCount() > 0) {
View textView = ((FrameLayout) v).getChildAt(0);
if (textView instanceof TextView) {
updateTextTab(i, textView);
}
}
if (v instanceof TextView) {
updateTextTab(i, v);
}
}
}
示例12: getView
import android.view.View; //导入方法依赖的package包/类
@Override
public View getView(int position, View v, ViewGroup parent) {
try {
if (v == null) v = getActivity().getLayoutInflater().inflate(R.layout.listeelem_2linjer, parent, false);
AQuery aq = new AQuery(v);
Pair elem = (Pair) liste.get(position);
Backend b = (Backend) elem.first;
Object obj = elem.second;
if (obj instanceof Programserie) {
Programserie ps = (Programserie) obj;
aq.id(R.id.linje1).text(ps.titel).typeface(App.skrift_gibson_fed).textColor(Color.BLACK);
int n = b.favoritter.getAntalNyeUdsendelser(ps.slug);
String txt = (n == 1 ? n + getString(R.string._ny_udsendelse) : n + getString(R.string._nye_udsendelser));
aq.id(R.id.linje2).text(txt).typeface(App.skrift_gibson);
aq.id(R.id.stiplet_linje).visibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
} else {
Udsendelse udsendelse = (Udsendelse) obj;
aq.id(R.id.linje1).text(Datoformater.datoformat.format(udsendelse.startTid)).typeface(App.skrift_gibson);
aq.id(R.id.linje2).text(udsendelse.titel).typeface(App.skrift_gibson);
aq.id(R.id.stiplet_linje).visibility(View.VISIBLE);
}
v.setBackgroundResource(0);
} catch (Exception e) {
Log.rapporterFejl(e);
}
return v;
}
示例13: setBackground
import android.view.View; //导入方法依赖的package包/类
public void setBackground(View view) {
if ((mFragment.getTag() != null && mFragment.getTag().startsWith("android:switcher:")) ||
mRootStatus != STATUS_UN_ROOT ||
view.getBackground() != null) {
return;
}
int defaultBg = mSupport.getSupportDelegate().getDefaultFragmentBackground();
if (defaultBg == 0) {
int background = getWindowBackground();
view.setBackgroundResource(background);
} else {
view.setBackgroundResource(defaultBg);
}
}
示例14: onViewCreated
import android.view.View; //导入方法依赖的package包/类
public void onViewCreated(View view, Bundle savedInstanceState) {
// Use window background as the top level background.
// Note: The view is an instance of NoSaveStateFrameLayout,
// which is inserted between the Fragment's view and its container by FragmentManager.
TypedValue outValue = new TypedValue();
getFragmentContext().getTheme().resolveAttribute(android.R.attr.windowBackground, outValue, true);
view.setBackgroundResource(outValue.resourceId);
// Set the "clickable" of the fragment's root view to true to avoid
// touch events to be passed to the views behind the fragment.
view.setClickable(true);
if (getFragmentMaster() != null) {
getFragmentMaster().dispatchFragmentViewCreated(mMasterFragment);
}
}
示例15: setupUnitCategory
import android.view.View; //导入方法依赖的package包/类
private void setupUnitCategory(HomeCategoryEntity homeCategoryEntity, final int index) {
MasterCategoryEntity categoryEntity = homeCategoryEntity.getCategoryEntity();
String cateName = categoryEntity.getCateName();
final int picResId = categoryEntity.getPicResId();
final List<ProductEntity> productEntityList = homeCategoryEntity.getProductEntityList();
LinearLayout unitContainer = new LinearLayout(getContext());
unitContainer.setOrientation(LinearLayout.VERTICAL);
unitContainer.setGravity(Gravity.CENTER_VERTICAL);
unitContainer.setBackgroundResource(R.color.bg_default_category);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(getResources().getInteger(R.integer.category_unit_height), getContext()));
layoutParams.gravity = Gravity.CENTER;
unitContainer.setLayoutParams(layoutParams);
final ImageView imgIcon = new ImageView(getAttachActivity());
int length = DisplayUtil.dip2px(32, getAttachActivity());
LinearLayout.LayoutParams iconLp = new LinearLayout.LayoutParams(length, length);
iconLp.gravity = Gravity.CENTER_HORIZONTAL;
imgIcon.setLayoutParams(iconLp);
imgIcon.setImageResource(picResId);
final TextView tvCategory = new TextView(getContext());
LinearLayout.LayoutParams tvLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
tvLp.gravity = Gravity.CENTER_HORIZONTAL;
tvCategory.setLayoutParams(tvLp);
tvCategory.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
tvCategory.setTextColor(getAttachActivity().getResources().getColor(R.color.font_red));
tvCategory.setText(cateName);
tvCategory.setVisibility(View.GONE);
View lineView = new View(getContext());
LinearLayout.LayoutParams lineLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
lineView.setLayoutParams(lineLp);
lineView.setBackgroundResource(R.color.line);
mUnitCategoryLayoutList.add(unitContainer);
mTvCategoryNameList.add(tvCategory);
mImgCategoryIconList.add(imgIcon);
unitContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reactionToClickCategory(index, productEntityList);
}
});
unitContainer.addView(imgIcon);
unitContainer.addView(tvCategory);
mContainerCategory.addView(unitContainer);
mContainerCategory.addView(lineView);
}