Java Code Examples for android.widget.ImageView#setBackgroundResource()

The following examples show how to use android.widget.ImageView#setBackgroundResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ControlActivity.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
private void initView() {
	mNameTitle = (TextView) findViewById(R.id.media_tv_title);
	mAuthorName = (TextView) findViewById(R.id.media_tv_author);

	mPlayBtn = (ImageView) findViewById(R.id.media_iv_play);
	mVoicePlus = (ImageView) findViewById(R.id.media_iv_voc_plus);
	mVoiceCut = (ImageView) findViewById(R.id.media_iv_voc_cut);
	mVoiceMute = (ImageView) findViewById(R.id.media_iv_voc_mute);
	mPlayBtn.setOnClickListener(this);
	mVoicePlus.setOnClickListener(this);
	mVoiceCut.setOnClickListener(this);
	mVoiceMute.setOnClickListener(this);
	mPlayBtn.setBackgroundResource(R.drawable.icon_media_pause);
	mVoiceMute.setBackgroundResource(R.drawable.icon_voc_mute);

	mCurrentTime = (TextView) findViewById(R.id.media_tv_time);
	mTotalTime = (TextView) findViewById(R.id.media_tv_total_time);

	mSeekBar = (SeekBar) findViewById(R.id.media_seekBar);
	mSeekBar.setOnSeekBarChangeListener(new PlaySeekBarListener());
}
 
Example 2
Source File: StationDetailAty.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
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]);
}
 
Example 3
Source File: LocalAlbumActivity.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
	if (convertView == null)
	{
		convertView = getLayoutInflater().inflate(R.layout.local_album_grid_list_item, parent, false);
	}
	ImageView image = ViewUtils.get(convertView, R.id.image);
	ImageView background = ViewUtils.get(convertView, R.id.background);
	TextView name_number = ViewUtils.get(convertView, R.id.name_number);
	
	AlbumInfo albumInfo = getItem(position);
	name_number.setText(getString(R.string.name_number, albumInfo.getName(), albumInfo.getPicnum()));
	background.setBackgroundResource(IMAGE_BACKGROUND[position % IMAGE_BACKGROUND.length]);
	mImageLoader.displayImage(albumInfo.getCoverurl(), image, mOptions);

	return convertView;
}
 
Example 4
Source File: BookOnlineActivity.java    From coolreader with MIT License 6 votes vote down vote up
public View getView(final int position, View convertView, ViewGroup parent)
{       
    layout = (LinearLayout) getLayoutInflater().inflate(R.layout.book_online_lv_item, null);
    ivbookCover = (ImageView)layout.findViewById(R.id.ivBookCover);
    tvbookName = (TextView)layout.findViewById(R.id.tvBookName);;
    tvbookDetail = (TextView)layout.findViewById(R.id.tvBookDetail);
    btnDownload = (Button)layout.findViewById(R.id.btnDownload);
         
    ivbookCover.setBackgroundResource(bookIconRes[position]);
    tvbookName.setText(bookNames[position]);
    tvbookDetail.setText(bookDetails[position]);
    btnDownload.setOnClickListener(new OnClickListener()
    {
        public void onClick(View v)
        {
            currentPosition = position;
            startDownload(layout);
        }
    });
         
    return layout;
}
 
Example 5
Source File: MainActivity.java    From ParallaxSplash with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    container = (ParallaxContainer) findViewById(R.id.parallax_container);
    container.setUp(new int[]{
            R.layout.view_intro_1,
            R.layout.view_intro_2,
            R.layout.view_intro_3,
            R.layout.view_intro_4,
            R.layout.view_intro_5,
            R.layout.view_login,
    });

    iv_man = (ImageView) findViewById(R.id.iv_man);
    container.setImage(iv_man);
    iv_man.setBackgroundResource(R.anim.man_run);
}
 
Example 6
Source File: NineGridViewAdapter.java    From myapplication with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.find_grid_item, parent, false);
    }

    TextView textView = NineBaseViewHolder.get(convertView, R.id.tv_item);
    ImageView imageView = NineBaseViewHolder.get(convertView, R.id.iv_item);
    imageView.setBackgroundResource(imgs[position]);
    textView.setText(img_text[position]);

    return convertView;
}
 
Example 7
Source File: GuideActivity.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化数据
 */
private void initData() {

    for (int i = 0; i < imgRes.length; i++) {
        View inflate = getLayoutInflater().inflate(R.layout.guide_item, null);
        ImageView ivGuide = (ImageView) inflate.findViewById(R.id.iv_guide);
        ivGuide.setBackgroundResource(imgRes[i]);
        mViewList.add(inflate);
    }
}
 
Example 8
Source File: ThemeClass.java    From heads-up with GNU General Public License v3.0 5 votes vote down vote up
/**
 Set the notification icon from a bitmap.
 */
public void setIcon(ImageView imageView, Bitmap bitmap, boolean round_icons, int color) {
    if (bitmap == null) return;
    if (round_icons) {
        final double minimumWidthForRoundIcon = imageView.getContext().getResources().
                getDimension(R.dimen.notification_ic_size) / (2 * Math.cos(Math.toRadians(45)));
        int bitmapWidth = bitmap.getWidth();
        Mlog.v(bitmapWidth, minimumWidthForRoundIcon);

        if (bitmapWidth >= minimumWidthForRoundIcon) {
            try {
                RoundDrawable roundedDrawable = new RoundDrawable(bitmap);
                imageView.setImageDrawable(roundedDrawable);
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            } catch (Exception e) {
                e.printStackTrace();
                imageView.setImageBitmap(bitmap);
            }
        } else {
            imageView.setImageBitmap(bitmap);
        }
        imageView.setBackgroundResource(R.drawable.circle_grey);
        setColor(imageView, color);
    } else {
        imageView.setImageBitmap(bitmap);
        setColor(imageView, color);
    }
}
 
Example 9
Source File: GglMapCustomMarkerView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public BitmapDescriptor createCustomMarkerViewForP2P(Context context, int res, float heightVale, int npos) {
    View view = LayoutInflater.from(context).inflate(R.layout.x8_map_custom_mark_view_for_point, null);
    ((TextView) view.findViewById(R.id.point_heightValue)).setText(X8NumberUtil.getDistanceNumberString(heightVale, 0, true));
    ImageView imageView = (ImageView) view.findViewById(R.id.markerIcon);
    if (res != 0) {
        imageView.setBackgroundResource(res);
    }
    return BitmapDescriptorFactory.fromBitmap(loadBitmapFromView(view, context));
}
 
Example 10
Source File: ViewPagerWithIndicator.java    From ViewPagerWithIndicator with MIT License 5 votes vote down vote up
private void populateView() {
    if (mArrowEnable) {
        //Populate arrow+viewPager container
        ((ViewGroup)mViewPager.getParent()).removeView(mViewPager);
        ((LayoutParams) mViewPager.getLayoutParams()).weight = 1;

        arrowContainer.addView(mLeftArrow);
        arrowContainer.addView(mViewPager);
        arrowContainer.addView(mRightArrow);

        updateArrowVisibility();
    }

    if (mRoundEnable) {
        //populate roundedIndicator container
        LayoutParams params = new LayoutParams(mRoundSize, mRoundSize);

        for (int i=0; i < mViewPager.getAdapter().getCount(); i++) {
            ImageView roundIndicator = new ImageView(getContext());
            roundIndicator.setBackgroundResource(mRoundDrawable);
            roundIndicator.setLayoutParams(params);

            roundedIndicatorContainer.addView(roundIndicator);
        }
        updateRoundIndicator();
    }
}
 
Example 11
Source File: CommProgressDialog.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
public void onWindowFocusChanged(boolean hasFocus){

        if (commProgressDialog == null){
            return;
        }

        ImageView imageView = (ImageView) commProgressDialog.findViewById(R.id.iv_loading);
        if(anim!=0) {
            imageView.setBackgroundResource(anim);
        }
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
        animationDrawable.start();
    }
 
Example 12
Source File: Slider.java    From AlarmOn with Apache License 2.0 5 votes vote down vote up
public Slider(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  // Setup the background which 'holds' the slider.
  tray = new TextView(getContext());
  tray.setBackgroundResource(R.drawable.slider_background);
  tray.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  tray.setGravity(Gravity.CENTER);

  if (Build.VERSION.SDK_INT < 23) {
      tray.setTextAppearance(getContext(), R.style.SliderText);
  } else {
      tray.setTextAppearance(R.style.SliderText);
  }

  tray.setText(R.string.dismiss);
  addView(tray);

  // Setup the object which will be slid.
  dot = new ImageView(getContext());
  dot.setImageResource(R.drawable.ic_forward);
  dot.setBackgroundResource(R.drawable.slider_btn);
  dot.setScaleType(ScaleType.CENTER);
  dot.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  dot.setPadding(30, 10, 25, 15);
  addView(dot);

  reset();
}
 
Example 13
Source File: IconCardPresenter.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected ImageCardView onCreateView() {
    final ImageCardView imageCardView = super.onCreateView();
    final ImageView image = imageCardView.getMainImageView();
    image.setBackgroundResource(R.drawable.icon_focused);
    image.getBackground().setAlpha(0);
    imageCardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            animateIconBackground(image.getBackground(), hasFocus);
        }
    });
    return imageCardView;
}
 
Example 14
Source File: Snap2Adapter.java    From YCBanner with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindData(BaseViewHolder holder, Integer data) {
    Integer integer = getData().get(getViewPosition() % getData().size());
    ImageView imageView = holder.getView(R.id.iv_image);
    imageView.setBackgroundResource(integer);
}
 
Example 15
Source File: UpdateDialog.java    From AppUpdate with Apache License 2.0 4 votes vote down vote up
private void initView(View view) {
    View ibClose = view.findViewById(R.id.ib_close);
    ImageView ivBg = view.findViewById(R.id.iv_bg);
    TextView title = view.findViewById(R.id.tv_title);
    TextView size = view.findViewById(R.id.tv_size);
    TextView description = view.findViewById(R.id.tv_description);
    progressBar = view.findViewById(R.id.np_bar);
    progressBar.setVisibility(forcedUpgrade ? View.VISIBLE : View.GONE);
    update = view.findViewById(R.id.btn_update);
    update.setTag(0);
    View line = view.findViewById(R.id.line);
    update.setOnClickListener(this);
    ibClose.setOnClickListener(this);
    //自定义
    if (dialogImage != -1) {
        ivBg.setBackgroundResource(dialogImage);
    }
    if (dialogButtonTextColor != -1) {
        update.setTextColor(dialogButtonTextColor);
    }
    if (dialogButtonColor != -1) {
        StateListDrawable drawable = new StateListDrawable();
        GradientDrawable colorDrawable = new GradientDrawable();
        colorDrawable.setColor(dialogButtonColor);
        colorDrawable.setCornerRadius(DensityUtil.dip2px(context, 3));
        drawable.addState(new int[]{android.R.attr.state_pressed}, colorDrawable);
        drawable.addState(new int[]{}, colorDrawable);
        update.setBackgroundDrawable(drawable);
    }
    if (dialogProgressBarColor != -1) {
        progressBar.setReachedBarColor(dialogProgressBarColor);
        progressBar.setProgressTextColor(dialogProgressBarColor);
    }
    //强制升级
    if (forcedUpgrade) {
        line.setVisibility(View.GONE);
        ibClose.setVisibility(View.GONE);
        setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                //屏蔽返回键
                return keyCode == KeyEvent.KEYCODE_BACK;
            }
        });
    }
    //设置界面数据
    if (!TextUtils.isEmpty(manager.getApkVersionName())) {
        String newVersion = context.getResources().getString(R.string.dialog_new);
        title.setText(String.format(newVersion, manager.getApkVersionName()));
    }
    if (!TextUtils.isEmpty(manager.getApkSize())) {
        String newVersionSize = context.getResources().getString(R.string.dialog_new_size);
        size.setText(String.format(newVersionSize, manager.getApkSize()));
        size.setVisibility(View.VISIBLE);
    }
    description.setText(manager.getApkDescription());
}
 
Example 16
Source File: UpdateDialog.java    From AppUpdate with Apache License 2.0 4 votes vote down vote up
private void initView(View view) {
    View ibClose = view.findViewById(R.id.ib_close);
    ImageView ivBg = view.findViewById(R.id.iv_bg);
    TextView title = view.findViewById(R.id.tv_title);
    TextView size = view.findViewById(R.id.tv_size);
    TextView description = view.findViewById(R.id.tv_description);
    progressBar = view.findViewById(R.id.np_bar);
    progressBar.setVisibility(forcedUpgrade ? View.VISIBLE : View.GONE);
    update = view.findViewById(R.id.btn_update);
    update.setTag(0);
    View line = view.findViewById(R.id.line);
    update.setOnClickListener(this);
    ibClose.setOnClickListener(this);
    //自定义
    if (dialogImage != -1) {
        ivBg.setBackgroundResource(dialogImage);
    }
    if (dialogButtonTextColor != -1) {
        update.setTextColor(dialogButtonTextColor);
    }
    if (dialogButtonColor != -1) {
        StateListDrawable drawable = new StateListDrawable();
        GradientDrawable colorDrawable = new GradientDrawable();
        colorDrawable.setColor(dialogButtonColor);
        colorDrawable.setCornerRadius(DensityUtil.dip2px(context, 3));
        drawable.addState(new int[]{android.R.attr.state_pressed}, colorDrawable);
        drawable.addState(new int[]{}, colorDrawable);
        update.setBackgroundDrawable(drawable);
    }
    if (dialogProgressBarColor != -1) {
        progressBar.setReachedBarColor(dialogProgressBarColor);
        progressBar.setProgressTextColor(dialogProgressBarColor);
    }
    //强制升级
    if (forcedUpgrade) {
        line.setVisibility(View.GONE);
        ibClose.setVisibility(View.GONE);
        setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                //屏蔽返回键
                return keyCode == KeyEvent.KEYCODE_BACK;
            }
        });
    }
    //设置界面数据
    if (!TextUtils.isEmpty(manager.getApkVersionName())) {
        String newVersion = context.getResources().getString(R.string.dialog_new);
        title.setText(String.format(newVersion, manager.getApkVersionName()));
    }
    if (!TextUtils.isEmpty(manager.getApkSize())) {
        String newVersionSize = context.getResources().getString(R.string.dialog_new_size);
        size.setText(String.format(newVersionSize, manager.getApkSize()));
        size.setVisibility(View.VISIBLE);
    }
    description.setText(manager.getApkDescription());
}
 
Example 17
Source File: FollowList.java    From ShareSDKShareDifMsgDemo-Android with MIT License 4 votes vote down vote up
public void onCreate() {
	LinearLayout llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xfff5f5f5);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	// 标题栏
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(getContext(), "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(getContext(), "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(getContext(), "finish");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	FrameLayout flPage = new FrameLayout(getContext());
	LinearLayout.LayoutParams lpFl = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpFl.weight = 1;
	flPage.setLayoutParams(lpFl);
	llPage.addView(flPage);

	// 关注(或朋友)列表
	PullToRefreshView followList = new PullToRefreshView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);
	adapter = new FollowAdapter(followList);
	adapter.setPlatform(platform);
	followList.setAdapter(adapter);
	adapter.getListView().setOnItemClickListener(this);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(getContext(), "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

	// 请求数据
	followList.performPulling(true);
}
 
Example 18
Source File: SelectOneAutoAdvanceWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    LayoutInflater inflater = LayoutInflater.from(getContext());

    mItems = getSelectChoices();
    buttons = new Vector<>();
    listener = (AdvanceToNextListener)context;

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {

            RelativeLayout thisParentLayout =
                    (RelativeLayout)inflater.inflate(R.layout.quick_select_layout, null);

            final LinearLayout questionLayout = (LinearLayout)thisParentLayout.getChildAt(0);
            ImageView rightArrow = (ImageView)thisParentLayout.getChildAt(1);

            final RadioButton r = new RadioButton(getContext());
            r.setOnCheckedChangeListener(this);
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                r.setText(forceMarkdown(markdownText));
            } else {
                r.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);
            r.setId(i + buttonIdBase);
            r.setEnabled(!prompt.isReadOnly());
            r.setFocusable(!prompt.isReadOnly());

            Drawable image = getResources().getDrawable(R.drawable.icon_auto_advance_arrow);
            rightArrow.setImageDrawable(image);
            rightArrow.setOnTouchListener((v, event) -> {
                r.onTouchEvent(event);
                return false;
            });

            buttons.add(r);

            if (mItems.get(i).getValue().equals(s)) {
                r.setChecked(true);
            }

            String audioURI = null;
            audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI = null;
            imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), r, audioURI, imageURI, videoURI, bigImageURI);

            questionLayout.addView(mediaLayout);

            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                mediaLayout.addDivider(divider);
            }

            addView(thisParentLayout);
        }
    }
}
 
Example 19
Source File: ActivityChooseRootEvent.java    From LibreTasks with Apache License 2.0 4 votes vote down vote up
/**
 * This function will be called once for every element in the listView control, when it needs to
 * draw itself. It should return a constructed view representing the data in the position
 * specified. Each element in the listView is an Event item, so we display the Event's icon and
 * title.
 * 
 * TODO: Use convertView when possible instead of always creating new views.
 */
public View getView(int position, View convertView, ViewGroup parent) {
  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  // Icon of the event.
  ImageView iv = new ImageView(context);
  iv.setImageResource(events.get(position).getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  // Title of the event.
  TextView tv = new TextView(context);
  String text = events.get(position).getDescriptionShort();

  int numOfRules = UIDbHelperStore.instance().db().getRuleCount(
      events.get(position).getDatabaseId());
  if (numOfRules == 1) {
    text += getString(R.string.one_rule);
  } else if (numOfRules > 1) {
    text += getString(R.string.n_rules, numOfRules);
  }

  tv.setText(text);
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  ll.addView(iv);
  ll.addView(tv);

  return ll;
}
 
Example 20
Source File: SampleActivity.java    From stateLayout with Apache License 2.0 4 votes vote down vote up
@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_content:
                stateLayout.showContentView();
//                stateLayout.setTipText(StateLayout.EMPTY, "12345");
//                stateLayout.setTipImg(StateLayout.EMPTY, R.mipmap.ic_launcher);
                break;
            case R.id.btn_empty:
                stateLayout.showEmptyView();
//                stateLayout.setTipText(StateLayout.ERROR, "12345");
//                stateLayout.setTipImg(StateLayout.ERROR, R.mipmap.ic_launcher);
                break;
            case R.id.btn_error:
                stateLayout.showErrorView();
//                stateLayout.setTipText(StateLayout.LOADING, "12345");
                break;
            case R.id.btn_loading:
                stateLayout.showLoadingView();
//                stateLayout.setTipText(StateLayout.TIMEOUT, "12345");
//                stateLayout.setTipImg(StateLayout.TIMEOUT, R.mipmap.ic_launcher);
                break;
            case R.id.btn_loading_no_tip:
                ImageView imageView = new ImageView(this);
                imageView.setBackgroundResource(R.color.colorPrimary);
                ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(300, 300);
                imageView.setLayoutParams(layoutParams);
                stateLayout.showLoadingView(imageView, false);
//                stateLayout.setTipText(StateLayout.TIMEOUT, "12345");
//                stateLayout.setTipImg(StateLayout.TIMEOUT, R.mipmap.ic_launcher);
                break;
            case R.id.btn_time_out:
                stateLayout.showTimeoutView();
//                stateLayout.setTipText(StateLayout.NOT_NETWORK, "12345");
//                stateLayout.setTipImg(StateLayout.NOT_NETWORK, R.mipmap.ic_launcher);
                break;
            case R.id.btn_not_network:
                stateLayout.showNoNetworkView();
                break;
            case R.id.btn_login:
                stateLayout.showLoginView();
                break;
            case R.id.btn_custom:
//                View customView = LayoutInflater.from(this).inflate(R.layout.layout_custom_view, null);
                stateLayout.showCustomView(rlCustom);
                break;
        }
    }