下面列出了android.widget.ProgressBar#setId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public LinearLayout makell(int id){
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TextView tv = new TextView(this);
tv.setText(((uninstall)?"uninstalling ":"installing ")+MainActivity.checks[id].text);
ll.addView(tv);
if(!uninstall){
ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
pb.setId(1);
pb.setProgress(0);
pb.setMax(100);
ll.addView(pb);
TextView tv1 = new TextView(this);
tv1.setId(2);
tv1.setText("0/0kb 0/100%");
ll.addView(tv1);
}
return ll;
}
static View getProgressWaitingItem() {
ProgressBar cslp_progress_bar_waiting = new ProgressBar(G.context);
cslp_progress_bar_waiting.setId(R.id.cslp_progress_bar_waiting);
cslp_progress_bar_waiting.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
cslp_progress_bar_waiting.setVisibility(View.VISIBLE);
FrameLayout.LayoutParams layout_842 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layout_842.gravity = Gravity.CENTER;
cslp_progress_bar_waiting.setIndeterminate(true);
cslp_progress_bar_waiting.setLayoutParams(layout_842);
return cslp_progress_bar_waiting;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View customLayout = mController.onCreateView(inflater, container, savedInstanceState);
if (customLayout != null) {
return customLayout;
}
final Context context = inflater.getContext();
FrameLayout root = new FrameLayout(context);
root.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
WebView wv = new WebView(context);
wv.setId(android.R.id.primary);
root.addView(wv, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
LinearLayout pframe = new LinearLayout(context);
pframe.setId(android.R.id.widget_frame);
pframe.setOrientation(LinearLayout.VERTICAL);
pframe.setVisibility(View.GONE);
pframe.setGravity(Gravity.CENTER);
ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
progress.setId(android.R.id.progress);
pframe.addView(progress, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
TextView progressText = new TextView(context, null, android.R.attr.textViewStyle);
progressText.setId(android.R.id.text1);
pframe.addView(progressText, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
root.addView(pframe, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
return root;
}
public EBrowserToast(Context context) {
super(context);
GradientDrawable grade = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
new int[]{0x99000000, 0x99000000});
grade.setCornerRadius(6);
setBackgroundDrawable(grade);
int pad = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
5, ESystemInfo.getIntence().mDisplayMetrics);
setPadding(pad, pad, pad, pad);
m_progress = new ProgressBar(context);
m_progress.setId(0x1101);
m_progress.setIndeterminate(true);
m_msg = new TextView(context);
m_msg.setId(0x1102);
int use = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
20, ESystemInfo.getIntence().mDisplayMetrics);
RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
parmPro.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
parmPro.addRule(RelativeLayout.CENTER_VERTICAL);
m_progress.setLayoutParams(parmPro);
m_progress.setMinimumHeight(10);
RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
parmMsg.addRule(RelativeLayout.RIGHT_OF, 0x1101);
parmMsg.addRule(RelativeLayout.CENTER_VERTICAL);
m_msg.setLayoutParams(parmMsg);
m_msg.setTextColor(0xFFFFFFFF);
m_msg.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
addView(m_progress);
addView(m_msg);
}
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);
}