当前位置: 首页>>代码示例>>Java>>正文


Java View.setBackgroundResource方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:Buildable.java

示例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;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:AlleUdsendelserAtilAA_frag.java

示例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);
    }
}
 
开发者ID:shucc,项目名称:Carousel,代码行数:28,代码来源:CarouselView.java

示例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;
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:22,代码来源:Buildable.java

示例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;
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:23,代码来源:Buildable.java

示例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;
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:22,代码来源:Buildable.java

示例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;
        }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:CircleIndicator.java

示例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");
    }
}
 
开发者ID:nicolkill,项目名称:SuperRecyclerView,代码行数:10,代码来源:SuperRecyclerAdapter.java

示例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);
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:15,代码来源:PreviewGeneralLayout.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:32,代码来源:TabPageIndicator.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:PagerSlidingTabStrip.java

示例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;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:31,代码来源:Favoritprogrammer_frag.java

示例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);
    }
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:16,代码来源:SupportFragmentDelegate.java

示例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);
    }
}
 
开发者ID:alphater,项目名称:garras,代码行数:15,代码来源:MasterFragmentDelegate.java

示例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);
}
 
开发者ID:Sugarya,项目名称:Closet,代码行数:53,代码来源:ClosetFragment.java


注:本文中的android.view.View.setBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。