本文整理汇总了Java中android.widget.ProgressBar.setId方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressBar.setId方法的具体用法?Java ProgressBar.setId怎么用?Java ProgressBar.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.setId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UploadView
import android.widget.ProgressBar; //导入方法依赖的package包/类
public UploadView(Context context, String uploadId, Bitmap bm, String title, String statusText, String pText, int progress) {
super(context);
idView = new TextView(context);
idView.setVisibility(View.GONE);
idView.setText(uploadId + "");
imageView = new ImageView(context);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0xFF666666);
imageView.setId(VIDEOIMAGE_ID);
titleView = new TextView(context);
titleView.setText(title);
titleView.setTextColor(0xFF000000);
titleView.setId(TITLEVIEW_ID);
titleView.setPaddingRelative(5, 5, 0, 0);
statusTextView = new TextView(context);
statusTextView.setText(statusText);
statusTextView.setTextColor(0xFF000000);
statusTextView.setId(STATUSVIEW_ID);
statusTextView.setPaddingRelative(5, 5, 0, 0);
statusTextView.setTextColor(Color.GRAY);
progressTextView = new TextView(context);
progressTextView.setText(pText);
progressTextView.setTextColor(0xFF000000);
progressTextView.setId(PROGRESSTEXT_ID);
progressTextView.setPaddingRelative(5, 5, 0, 0);
progressTextView.setTextColor(Color.GRAY);
progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
progressBar.setMax(100);
progressBar.setIndeterminate(false);
progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
progressBar.setId(PROGRESSBAR_ID);
progressBar.setPaddingRelative(5, 0, 0, 0);
progressBar.setProgress(progress);
/**
*
* + + + + title
* + img + 0M / 0M
* + + 下载中
* + + + + ********progress**************
*
* */
//左侧
LayoutParams imageLayoutParams = new LayoutParams(ParamsUtil.dpToPx(context, 75), ParamsUtil.dpToPx(context, 75));
imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//位于图片右侧
LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于标题下方
LayoutParams statusLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
statusLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
statusLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于状态下方
LayoutParams progressTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
progressTextParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
progressTextParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于图片左侧,进度文本下方
LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, ParamsUtil.dpToPx(context, 7));
progressBarLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
progressBarLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
progressBarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
addView(imageView, imageLayoutParams);
addView(titleView, titleLayoutParams);
addView(statusTextView, statusLayoutParams);
addView(progressTextView, progressTextParams);
addView(progressBar, progressBarLayoutParams);
setPadding(5, 5, 5, 5);
}
示例2: createClassicViews
import android.widget.ProgressBar; //导入方法依赖的package包/类
static void createClassicViews(RelativeLayout layout) {
TextView textViewTitle = new TextView(layout.getContext());
textViewTitle.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_title);
textViewTitle.setTextSize(12);
textViewTitle.setTextColor(Color.parseColor("#333333"));
TextView textViewLastUpdate = new TextView(layout.getContext());
textViewLastUpdate.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_last_update);
textViewLastUpdate.setTextSize(10);
textViewLastUpdate.setTextColor(Color.parseColor("#969696"));
textViewLastUpdate.setVisibility(View.GONE);
LinearLayout textContainer = new LinearLayout(layout.getContext());
textContainer.setOrientation(LinearLayout.VERTICAL);
textContainer.setGravity(Gravity.CENTER_HORIZONTAL);
textContainer.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_text_container);
LinearLayout.LayoutParams textViewTitleLP = new LinearLayout.LayoutParams(ViewGroup
.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textContainer.addView(textViewTitle, textViewTitleLP);
LinearLayout.LayoutParams textViewLastUpdateLP = new LinearLayout.LayoutParams(ViewGroup
.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textContainer.addView(textViewLastUpdate, textViewLastUpdateLP);
RelativeLayout.LayoutParams textContainerLP = new RelativeLayout.LayoutParams(ViewGroup
.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textContainerLP.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(textContainer, textContainerLP);
ImageView imageViewArrow = new ImageView(layout.getContext());
imageViewArrow.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_arrow);
RelativeLayout.LayoutParams imageViewArrowLP = new RelativeLayout.LayoutParams(ViewGroup
.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
final int dp6 = PixelUtl.dp2px(layout.getContext(), 6);
imageViewArrowLP.setMargins(dp6, dp6, dp6, dp6);
imageViewArrowLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
.sr_classic_text_container);
imageViewArrowLP.addRule(RelativeLayout.CENTER_VERTICAL);
layout.addView(imageViewArrow, imageViewArrowLP);
ProgressBar progressBar = new ProgressBar(layout.getContext(), null, android.R.attr
.progressBarStyleSmallInverse);
progressBar.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_progress);
RelativeLayout.LayoutParams progressBarLP = new RelativeLayout.LayoutParams(ViewGroup
.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
progressBarLP.setMargins(dp6, dp6, dp6, dp6);
progressBarLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
.sr_classic_text_container);
progressBarLP.addRule(RelativeLayout.CENTER_VERTICAL);
layout.addView(progressBar, progressBarLP);
}