當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.setBackgroundResource方法代碼示例

本文整理匯總了Java中android.widget.ImageView.setBackgroundResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setBackgroundResource方法的具體用法?Java ImageView.setBackgroundResource怎麽用?Java ImageView.setBackgroundResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.setBackgroundResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convert

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, NoteFolder item) {
    helper.setText(R.id.tv_folder_list_title, item.getFolderName())
            .setText(R.id.tv_folder_list_count, item.getNoteCount() + "");


    RelativeLayout rlItem=helper.getView(R.id.rl_folder_root);
    TextView tvTitle=helper.getView(R.id.tv_folder_list_title);
    TextView tvCount=helper.getView(R.id.tv_folder_list_count);
    ImageView ivIcon=helper.getView(R.id.iv_folder_list_ic);

    if(Constans.currentFolder == helper.getLayoutPosition()-getHeaderLayoutCount()){
        rlItem.setSelected(true);
        tvTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
        tvCount.setTextColor(ThemeUtils.getColorPrimary(mContext));
        ivIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable( ThemeUtils.getColorPrimary(mContext)));
    } else {
        rlItem.setSelected(false);
        tvTitle.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha87));
        tvCount.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha54));
        ivIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
    }
}
 
開發者ID:ifadai,項目名稱:SuperNote,代碼行數:24,代碼來源:RvNoteFolderAdapter.java

示例2: loadViews

import android.widget.ImageView; //導入方法依賴的package包/類
public void loadViews() {
	titles = new String[mMapBitmaps.size()];
	mPics = new ArrayList<ImageView>();
	mDots = new ArrayList<View>();
	int i=0;
	for(String key:mMapBitmaps.keySet()){
		titles[i++] = key;
		ImageView iv1 = new ImageView(StationDetailAty.this);
		iv1.setImageBitmap(mMapBitmaps.get(key));
		iv1.setScaleType(ScaleType.CENTER_CROP);
		iv1.setOnClickListener(new MyOnClickListener(i));
		mPics.add(iv1);
		
		ImageView iv2 = new ImageView(StationDetailAty.this);
		iv2.setBackgroundResource(R.drawable.dot_normal);
		mDots.add(iv2);
	}
	tvTitle.setText(titles[0]);
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:20,代碼來源:StationDetailAty.java

示例3: initIconView

import android.widget.ImageView; //導入方法依賴的package包/類
private View initIconView() {
    FrameLayout contentView = new FrameLayout(LiteIconActivity.this);
    int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
    int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
    ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
    contentView.setLayoutParams(lpCv);

    ImageView ivIcon = new ImageView(LiteIconActivity.this);
    ivIcon.setTag("iv");
    ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ivIcon.setClickable(true);
    ivIcon.setBackgroundResource(getClickBg());
    int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
    FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
    lpIv.gravity = Gravity.CENTER;
    ivIcon.setLayoutParams(lpIv);
    contentView.addView(ivIcon);

    return contentView;
}
 
開發者ID:by-syk,項目名稱:NanoIconPackLite,代碼行數:21,代碼來源:LiteIconActivity.java

示例4: onCreate

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTitle(title);
    infoText = (TextView) findViewById(R.id.infoView);
    imgView = (ImageView) findViewById(R.id.cardbg);
    imgView.setBackgroundResource(R.drawable.myanim);
    _animation = (AnimationDrawable) imgView.getBackground();
    _animation.setOneShot(false);
    uiHandler = new MyHandler(this);

    mBluetoothReader = new BluetoothReader();
    mBluetoothReader.setOnReaderStateListener(new BluetoothReader.OnReaderStateListener() {
        @Override
        public void onReaderStateChange(String readerName, int readerState) {
            if (readerName.isEmpty() == false) {
                uiHandler.obtainMessage(READER_MESSAGE, readerState, -1, readerName).sendToTarget();
            }
        }
    });

    View scan = findViewById(R.id.btScan);
    scan.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            infoText.setText("Select bluetooth reader for connect...");
            Intent serverIntent = new Intent(TestActivity3.this, DeviceListActivity.class);
            startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
        }
    });
}
 
開發者ID:NaOHAndroid,項目名稱:Logistics-guard,代碼行數:33,代碼來源:TestActivity3.java

示例5: startEditMode

import android.widget.ImageView; //導入方法依賴的package包/類
private void startEditMode(RecyclerView parent) {
    this.isEditMode = true;
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = parent.getChildAt(i);
        if (view != null) {
            ImageView imgEdit = (ImageView) view.findViewById(R.id.edit_tip);
            RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.item_group_id);
            if (layout != null) {
                layout.setBackgroundResource(R.drawable.channel_wall_item_selecter_bg);
            }
            if (imgEdit != null) {
                if (((Integer) imgEdit.getTag()).intValue() == 0) {
                    imgEdit.setBackgroundResource(2130837812);
                } else {
                    imgEdit.setBackgroundResource(2130837811);
                }
                imgEdit.setVisibility(0);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:23,代碼來源:ChannelFragmentAdapter.java

示例6: getView

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    ImageView img = new ImageView(context);
    img.setBackgroundResource(R.color.white);
    img.setPadding(2, 2, 2, 2);
    img.setScaleType(ImageView.ScaleType.CENTER_CROP);

    int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 117);// 獲取屏幕寬度
    int height = width = width / 4;// 對當前的列數進行設置imgView的寬度
    img.setLayoutParams(new AbsListView.LayoutParams(width, height));

    Glide
            .with(context)
            .load(Constants.PICTURE_URL + list.get(position))
            .override(width, height)
            .skipMemoryCache(true)
            .centerCrop()
            .crossFade()
            .placeholder(R.drawable.img_loading)
            .error(R.drawable.img_error)
            .into(img);

    return img;
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:25,代碼來源:SmallBitmapGridViewAdapter.java

示例7: onCreateViewHolder

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    FrameLayout contentView = new FrameLayout(LiteIconActivityV1.this);
    int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
    int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
    ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
    contentView.setLayoutParams(lpCv);

    ImageView ivIcon = new ImageView(LiteIconActivityV1.this);
    ivIcon.setTag("iv");
    ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
    ivIcon.setClickable(true);
    ivIcon.setBackgroundResource(getClickBg());
    int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
    FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
    lpIv.gravity = Gravity.CENTER;
    ivIcon.setLayoutParams(lpIv);
    contentView.addView(ivIcon);

    return new IconHolder(contentView);
}
 
開發者ID:by-syk,項目名稱:NanoIconPackLite,代碼行數:22,代碼來源:LiteIconActivityV1.java

示例8: initPointView

import android.widget.ImageView; //導入方法依賴的package包/類
public void initPointView(int size) {
    layout = new LinearLayout(context);
    for (int i = 0; i < size; i++) {
        ImageView imageView = new ImageView(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
        params.leftMargin = 8;
        params.gravity = Gravity.CENTER;
        imageView.setLayoutParams(params);
        if (i == 0) {
            imageView.setBackgroundResource(R.drawable.ic_point_checked);
        } else {
            imageView.setBackgroundResource(R.drawable.ic_point_normal);
        }
        layout.addView(imageView);
    }
    LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(ALIGN_PARENT_BOTTOM);
    layoutParams.addRule(CENTER_HORIZONTAL);

    layoutParams.setMargins(12, 20, 12, 20);
    layout.setLayoutParams(layoutParams);
    addView(layout);
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:24,代碼來源:AutoScrollViewPager.java

示例9: ViewPagerIndicator

import android.widget.ImageView; //導入方法依賴的package包/類
public ViewPagerIndicator(Context context, ViewPager viewPager, LinearLayout dotLayout, int size) {
    this.context = context;
    this.viewPager = viewPager;
    this.dotLayout = dotLayout;
    this.size = size;

    for(int i = 0; i < size; i++){
        ImageView imageView = new ImageView(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 10;
        params.rightMargin = 10;
        params.height = imgSize;
        params.width = imgSize;
        if(0 ==i){
            imageView.setBackgroundResource(imgSelected);
        }else {
            imageView.setBackgroundResource(imgNoselect);
        }
        dotLayout.addView(imageView, params);
        dotViewLists.add(imageView);

    }
}
 
開發者ID:liuyanggithub,項目名稱:SuperSelector,代碼行數:26,代碼來源:ViewPagerIndicator.java

示例10: getImageView

import android.widget.ImageView; //導入方法依賴的package包/類
private View getImageView(Context context, String imgUrl) {
    /* 設置某一頁麵的view */
    RelativeLayout relativeLayout = new RelativeLayout(context);
    ImageView imageView = new ImageView(context);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setLayoutParams(layoutParams);
    // 設置一個半透明的黑色背景,防止白字受白色圖片幹擾而無法顯示
    ImageView background = new ImageView(context);
    background.setLayoutParams(layoutParams);
    background.setBackgroundResource(R.color.colorCycleViewBannerBackground);
    relativeLayout.addView(imageView);
    relativeLayout.addView(background);
    Picasso.with(context).load(imgUrl).into(imageView);
    return relativeLayout;
}
 
開發者ID:hgs1217,項目名稱:Paper-Melody,代碼行數:18,代碼來源:MusicHallCycleViewPager.java

示例11: updatePointView

import android.widget.ImageView; //導入方法依賴的package包/類
public void updatePointView(int position) {
    int size = layout.getChildCount();
    for (int i = 0; i < size; i++) {
        ImageView imageView = (ImageView) layout.getChildAt(i);
        if (i == position) {
            imageView.setBackgroundResource(R.drawable.ic_point_checked);
        } else {
            imageView.setBackgroundResource(R.drawable.ic_point_normal);
        }
    }
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:12,代碼來源:AutoScrollViewPager.java

示例12: initAvatar

import android.widget.ImageView; //導入方法依賴的package包/類
private void initAvatar(ImageView avatar, Post post) {
    String avatar_url = this.user.avatar_url;
    if (post.user != null) {
        avatar_url = post.user.avatar_url;
    }
    if (TextUtils.isEmpty(avatar_url)) {
        avatar.setBackgroundResource(R.drawable.aa0);
    } else {
        this.imageLoader.displayImage(avatar_url, avatar, ImageLoaderOptions.avatar());
    }
    avatar.setOnClickListener(new AvatarClickListener(post));
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:UserTimelineAdapter.java

示例13: setupPillChildView

import android.widget.ImageView; //導入方法依賴的package包/類
private LinearLayout setupPillChildView(String pillMessage, boolean isPressed, int imgResource) {
    final LinearLayout lnlContainer = (LinearLayout) LayoutInflater.from(getContext())
            .inflate(R.layout.pills_box_layout, this, false);
    lnlContainer.setBackgroundResource(backgroundPill);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(pillMarginLeft, pillMarginTop, pillMarginRight, pillMarginBottom);
    lnlContainer.setLayoutParams(layoutParams);

    if (isPressed) {
        lnlContainer.setBackgroundResource(backgroundPillSelected);
    } else {
        lnlContainer.setBackgroundResource(backgroundPill);
    }

    //Inflating LinearLayout child for customization
    LinearLayout lnlChild = (LinearLayout) lnlContainer.findViewById(R.id.lnlChild);
    lnlChild.setPadding(pillPaddingLeft, pillPaddingTop, pillPaddingRight, pillPaddingBottom);

    //Inflating ImageView
    CirculateImageView civContact = (CirculateImageView) lnlContainer.findViewById(R.id.civContact);

    if (hideContactIcon) {
        civContact.setVisibility(View.VISIBLE);
    } else {
        civContact.setVisibility(View.GONE);
    }

    if (imgResource == 0) {
        civContact.setImageResource(R.drawable.ic_orbismobile);
    } else {
        civContact.setImageResource(imgResource);
    }
    //Inflating TextView child for customization
    TextView lblMessage = (TextView) lnlContainer.findViewById(R.id.lblMessage);
    lblMessage.setText(pillMessage);
    lblMessage.setTextColor(pillTextColor);
    //Inflating imgClose view for customization
    ImageView imgClose = (ImageView) lnlContainer.findViewById(R.id.imgClose);
    imgClose.setBackgroundResource(pillCloseIcon);
    if (hideCloseIcon) {
        imgClose.setVisibility(View.VISIBLE);
    } else {
        imgClose.setVisibility(View.GONE);
    }
    MarginLayoutParams marginLayoutParams = (MarginLayoutParams) imgClose.getLayoutParams();
    marginLayoutParams.leftMargin = closeIconMarginLeft;
    imgClose.setLayoutParams(marginLayoutParams);
    imgClose.setOnClickListener(this);
    lnlContainer.setOnClickListener(this);
    return lnlContainer;
}
 
開發者ID:orbismobile,項目名稱:android-MaterialPillsBox,代碼行數:52,代碼來源:MaterialPillsBox.java

示例14: onBindViewHolder

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(RecyclerViewAdapter.RecyclerViewHolder holder, int position)
{
	LocalAlbumActivity activity = mWeakReference.get();
	ImageView image = holder.findViewById(R.id.image);
	ImageView background = holder.findViewById(R.id.background);
	TextView name_number = holder.findViewById(R.id.name_number);
	
	AlbumInfo albumInfo = activity.mImageAdapter.getItem(position);
	name_number.setText(activity.getString(R.string.name_number, albumInfo.getName(), albumInfo.getPicnum()));
	background.setBackgroundResource(IMAGE_BACKGROUND[position % IMAGE_BACKGROUND.length]);
	activity.mImageLoader.displayImage(albumInfo.getCoverurl(), image, activity.mOptions);
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:14,代碼來源:LocalAlbumActivity.java

示例15: onCreate

import android.widget.ImageView; //導入方法依賴的package包/類
public void onCreate() {
    LinearLayout llPage = new LinearLayout(getContext());
    llPage.setBackgroundColor(-657931);
    llPage.setOrientation(1);
    this.activity.setContentView(llPage);
    this.llTitle = new TitleLayout(getContext());
    int resId = R.getBitmapRes(getContext(), "title_back");
    if (resId > 0) {
        this.llTitle.setBackgroundResource(resId);
    }
    this.llTitle.getBtnBack().setOnClickListener(this);
    resId = R.getStringRes(getContext(), "multi_share");
    if (resId > 0) {
        this.llTitle.getTvTitle().setText(resId);
    }
    this.llTitle.getBtnRight().setVisibility(0);
    resId = R.getStringRes(getContext(), SportPlanFragment.COURSE_STATUS_FINISH);
    if (resId > 0) {
        this.llTitle.getBtnRight().setText(resId);
    }
    this.llTitle.getBtnRight().setOnClickListener(this);
    this.llTitle.setLayoutParams(new LayoutParams(-1, -2));
    llPage.addView(this.llTitle);
    FrameLayout flPage = new FrameLayout(getContext());
    LayoutParams lpFl = new LayoutParams(-1, -2);
    lpFl.weight = 1.0f;
    flPage.setLayoutParams(lpFl);
    llPage.addView(flPage);
    PullToRefreshView followList = new PullToRefreshView(getContext());
    followList.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
    flPage.addView(followList);
    this.adapter = new FollowAdapter(followList);
    this.adapter.setPlatform(this.platform);
    followList.setAdapter(this.adapter);
    this.adapter.getListView().setOnItemClickListener(this);
    ImageView ivShadow = new ImageView(getContext());
    resId = R.getBitmapRes(getContext(), "title_shadow");
    if (resId > 0) {
        ivShadow.setBackgroundResource(resId);
    }
    ivShadow.setLayoutParams(new FrameLayout.LayoutParams(-1, -2));
    flPage.addView(ivShadow);
    followList.performPulling(true);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:45,代碼來源:FollowListPage.java


注:本文中的android.widget.ImageView.setBackgroundResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。