private void init() { setOrientation(LinearLayout.VERTICAL); textView = new TextView(getContext()); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); textView.setTextColor(0xff3b84c0); addView(textView); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.height = LayoutParams.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(8); layoutParams.rightMargin = AndroidUtilities.dp(8); layoutParams.topMargin = AndroidUtilities.dp(6); layoutParams.bottomMargin = AndroidUtilities.dp(4); if (LocaleController.isRTL) { textView.setGravity(Gravity.RIGHT); layoutParams.gravity = Gravity.RIGHT; } textView.setLayoutParams(layoutParams); View view = new View(getContext()); view.setBackgroundColor(0xff6caae4); addView(view); layoutParams = (LayoutParams) view.getLayoutParams(); layoutParams.weight = LayoutParams.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); view.setLayoutParams(layoutParams); }
public void showNumberLayout(List<ShowInfoBean> list) { LogUtil.e(getClass(), "showNumberLayout list size==>" + list.size()); showNumberLayout.removeAllViews(); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LinearLayout itemLayout = null; for (int i = 0; i < list.size(); i++) { LogUtil.e(getClass(), "showNumberLayout i==>" + i); if (i % 3 == 0) { itemLayout = (LinearLayout) LayoutInflater.from(showNumberLayout.getContext()).inflate(R.layout.show, null); itemLayout.setLayoutParams(layoutParams); showNumberLayout.addView(itemLayout); } RelativeLayout itemView = (RelativeLayout) LayoutInflater.from(showNumberLayout.getContext()).inflate(R.layout.show_item, null); initItem(itemView, list.get(i), i); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); params.setMargins(20, 20, 0, 0); params.weight = 1; itemView.setLayoutParams(params); itemLayout.addView(itemView); } }
private View addMenuButton(final MenuItem item) { final ImageButton actionButton = new ImageButton(mContext, null, R.attr.actionBarItemStyle); final LayoutParams params = new LayoutParams( (int) getResources().getDimension(R.dimen.actionbar_button_width), ViewGroup.LayoutParams.MATCH_PARENT); params.weight = 1; actionButton.setLayoutParams(params); actionButton.setImageDrawable(item.getIcon()); actionButton.setScaleType(ScaleType.CENTER); actionButton.setContentDescription(item.getTitle()); actionButton.setEnabled(item.isEnabled()); actionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(final View view) { if (!item.isEnabled()) return; if (item.hasSubMenu()) { mPopupMenu = PopupMenu.getInstance(mContext, view); mPopupMenu.setOnMenuItemClickListener(MenuBar.this); mPopupMenu.setMenu(item.getSubMenu()); mPopupMenu.show(); } else { if (mItemClickListener != null) { mItemClickListener.onMenuItemClick(item); } } } }); actionButton.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(final View v) { if (item.getItemId() == android.R.id.home) return false; final Toast t = Toast.makeText(mContext, item.getTitle(), Toast.LENGTH_SHORT); final int[] screenPos = new int[2]; v.getLocationOnScreen(screenPos); final int height = v.getHeight(); t.setGravity( Gravity.TOP | Gravity.LEFT, screenPos[0], (int) (screenPos[1] - height * 1.5)); t.show(); return true; } }); addView(actionButton); return actionButton; }
public LinearLayout createLayout(int orientation) { LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); lp.weight = 1; LinearLayout ll = new LinearLayout(getContext()); ll.setGravity(Gravity.CENTER_VERTICAL); ll.setOrientation(orientation); ll.setLayoutParams(lp); return ll; }
/** * 初始化布局容器 * * @param context */ private void init(Context context) { mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(HORIZONTAL); mTabLayout.setBackgroundColor(Color.WHITE); addView( mTabLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mTabParams = new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT); mTabParams.weight = 1; }
/** Config UI just one time */ private void configUI() { setOrientation(LinearLayout.VERTICAL); setPadding(8, 8, 8, 8); TextView titleView = new TextView(ctx); titleView.setText(TEXT_TITLE); titleView.setTextColor(Color.LTGRAY); addView(titleView); LinearLayout subLayout = new LinearLayout(ctx); subLayout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams subLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); // configuring the iconView iconView.setImageDrawable(icon); LayoutParams icParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); icParams.gravity = Gravity.CENTER_VERTICAL; // configuring the msgView msgView.setText(msg); msgView.setPadding(10, 0, 0, 0); msgView.setTextSize(20); msgView.setTextColor(Color.WHITE); msgView.setGravity(Gravity.CENTER_VERTICAL); msgView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); msgView.setMaxLines(1); LayoutParams tvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); subLayout.addView(iconView, icParams); subLayout.addView(msgView, tvParams); addView(subLayout, subLayoutParams); actionBtn.setText(TEXT_DELETE); actionBtn.setTextColor(Color.WHITE); addView(actionBtn, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); undoRedoLayout.setOrientation(LinearLayout.HORIZONTAL); undoView = new ImageView(ctx); redoView = new ImageView(ctx); undoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_UNDO)); redoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_REDO)); undoView.setClickable(true); redoView.setClickable(true); LayoutParams undoRedoParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); undoRedoParams.weight = 1; undoRedoLayout.addView(undoView, undoRedoParams); undoRedoLayout.addView(redoView, undoRedoParams); addView(undoRedoLayout); }
public UnderlineIndicatorView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(HORIZONTAL); int count = 4; for (int i = 0; i < count; i++) { View view = new View(context); LayoutParams params = new LayoutParams(0, LayoutParams.MATCH_PARENT); params.weight = 1; view.setLayoutParams(params); view.setBackgroundResource(R.color.transparent); addView(view); } }
public ImageView createImageView(int i, String url) { LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); lp.weight = 1; ImageView image = new ImageView(getContext()); image.setLayoutParams(lp); image.setScaleType(ScaleType.CENTER_CROP); image.setId(i); image.setTag(i); image.setOnClickListener(imgClick); image.setOnLongClickListener(longClick); if (imgList.size() < 3 || (imgList.size() < 4 && i == 0)) { ImageLoader.getInstance().displayImage(url + StaticFactory._600x600, image, options_defalut); } else { ImageLoader.getInstance().displayImage(url + StaticFactory._320x320, image, options_defalut); } return image; }
private LinearLayout getView(int position, OnClickListener ocL, Context context) { Bitmap logo; String label; OnClickListener listener; if (beans[position] instanceof Platform) { logo = getIcon((Platform) beans[position]); label = getName((Platform) beans[position]); listener = ocL; } else { logo = ((CustomerLogo) beans[position]).enableLogo; label = ((CustomerLogo) beans[position]).label; listener = ocL; } LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(context); int dp_5 = com.mob.tools.utils.R.dipToPx(context, 5); iv.setPadding(dp_5, dp_5, dp_5, dp_5); iv.setScaleType(ScaleType.CENTER_INSIDE); LayoutParams lpIv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpIv.setMargins(dp_5, dp_5, dp_5, dp_5); lpIv.gravity = Gravity.CENTER_HORIZONTAL; iv.setLayoutParams(lpIv); iv.setImageBitmap(logo); ll.addView(iv); TextView tv = new TextView(context); tv.setTextColor(0xff000000); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); tv.setSingleLine(); tv.setIncludeFontPadding(false); LayoutParams lpTv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpTv.gravity = Gravity.CENTER_HORIZONTAL; lpTv.weight = 1; lpTv.setMargins(dp_5, 0, dp_5, dp_5); tv.setLayoutParams(lpTv); tv.setText(label); ll.addView(tv); ll.setOnClickListener(listener); return ll; }
@Override public void addView(View child) { mHeaderView = new EBounceViewHeader(mContext, EViewEntry.F_BOUNCE_TYPE_TOP); LayoutParams hlp = new LinearLayout.LayoutParams(Compat.FILL, mBounceViewHeight); hlp.topMargin = -mBounceViewHeight; hlp.gravity = Gravity.CENTER; addView(mHeaderView, hlp); mHeaderView.setVisibility(GONE); mBrwView = (EBrowserView) child; LayoutParams wlp = new LinearLayout.LayoutParams(Compat.FILL, Compat.FILL); wlp.weight = 1.0f; addView(mBrwView, wlp); mTailView = new EBounceViewHeader(mContext, EViewEntry.F_BOUNCE_TYPE_BOTTOM); LayoutParams tlp = new LinearLayout.LayoutParams(Compat.FILL, mBounceViewHeight); tlp.bottomMargin = -mBounceViewHeight; tlp.gravity = Gravity.CENTER; addView(mTailView, tlp); mTailView.setVisibility(GONE); }
private void init() { int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 10); int scrW = getResources().getDisplayMetrics().widthPixels; iconWidth = (scrW - dp_10 * 2) / 3 - dp_10 * 4; setOrientation(VERTICAL); int size = platforms == null ? 0 : platforms.length; int lineSize = size / 3; if (size % 3 > 0) { lineSize++; } LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); lp.weight = 1; for (int i = 0; i < lines; i++) { LinearLayout llLine = new LinearLayout(getContext()); llLine.setLayoutParams(lp); addView(llLine); if (i >= lineSize) { continue; } for (int j = 0; j < 3; j++) { final int index = i * 3 + j; if (index >= size) { LinearLayout llItem = new LinearLayout(getContext()); llItem.setLayoutParams(lp); llLine.addView(llItem); continue; } final LinearLayout llItem = getView(index, getContext()); llItem.setTag(platforms[index]); llItem.setOnClickListener(callback); llItem.setLayoutParams(lp); llLine.addView(llItem); } } }
private void init() { int dp_5 = com.mob.tools.utils.R.dipToPx(getContext(), 5); setPadding(0, dp_5, 0, dp_5); setOrientation(VERTICAL); int size = beans == null ? 0 : beans.length; int COLUMN_PER_LINE = platformAdapter.platformGridView.COLUMN_PER_LINE; int lineSize = size / COLUMN_PER_LINE; if (size % COLUMN_PER_LINE > 0) { lineSize++; } LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lp.weight = 1; for (int i = 0; i < lines; i++) { LinearLayout llLine = new LinearLayout(getContext()); llLine.setLayoutParams(lp); llLine.setPadding(dp_5, 0, dp_5, 0); addView(llLine); if (i >= lineSize) { continue; } for (int j = 0; j < COLUMN_PER_LINE; j++) { final int index = i * COLUMN_PER_LINE + j; if (index >= size) { LinearLayout llItem = new LinearLayout(getContext()); llItem.setLayoutParams(lp); llLine.addView(llItem); continue; } final LinearLayout llItem = getView(index, callback, getContext()); llItem.setTag(beans[index]); llItem.setLayoutParams(lp); llLine.addView(llItem); } } }
public void handleCompletion() { removeAllViews(); TextView label = new TextView(this.getContext()); label.setText("Great work!!"); getVocabBlasterActivity().formatHandwritingOnAChalkboard(label); addView(label); label = new TextView(this.getContext()); label.setText("You have these words pretty well mastered."); getVocabBlasterActivity().formatHandwritingOnAChalkboard(label); Button button = new Button(this.getContext()); button.setText("Start Over"); button.setTextColor(Color.BLACK); LayoutParams layoutParams = new LayoutParams(); layoutParams.weight = 1.0f; float density = getResources().getDisplayMetrics().density; layoutParams.width = (int) (150 * density); layoutParams.topMargin = 60; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; button.setLayoutParams(layoutParams); final AdministerTestActivity vocabBlaster = (AdministerTestActivity) this.getContext(); button.setOnClickListener( new OnClickListener() { public void onClick(View view) { vocabBlaster.reset(); } }); addView(label); addView(button); }
public BottomBar(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BottomBar); image1 = ta.getDrawable(R.styleable.BottomBar_ImageView1); image2 = ta.getDrawable(R.styleable.BottomBar_ImageView2); image3 = ta.getDrawable(R.styleable.BottomBar_ImageView3); image4 = ta.getDrawable(R.styleable.BottomBar_ImageView4); image1Height = ta.getDimension(R.styleable.BottomBar_ImageView1Height, 50); image2Height = ta.getDimension(R.styleable.BottomBar_ImageView2Height, 0); image3Height = ta.getDimension(R.styleable.BottomBar_ImageView3Height, 0); image4Height = ta.getDimension(R.styleable.BottomBar_ImageView4Height, 0); image1Width = ta.getDimension(R.styleable.BottomBar_ImageView1Width, 50); image2Width = ta.getDimension(R.styleable.BottomBar_ImageView2Width, 0); image3Width = ta.getDimension(R.styleable.BottomBar_ImageView3Width, 0); image4Width = ta.getDimension(R.styleable.BottomBar_ImageView4Width, 0); ta.recycle(); imageView1 = new ImageView(context); imageView2 = new ImageView(context); imageView3 = new ImageView(context); imageView4 = new ImageView(context); imageView1.setImageDrawable(image1); imageView1.setAdjustViewBounds(true); imageView1.setMaxHeight((int) image1Height); imageView1.setMaxWidth((int) image1Width); imageView2.setImageDrawable(image2); imageView2.setAdjustViewBounds(true); imageView2.setMaxHeight((int) image2Height); imageView2.setMaxWidth((int) image2Width); imageView3.setImageDrawable(image3); imageView3.setAdjustViewBounds(true); imageView3.setMaxHeight((int) image3Height); imageView3.setMaxWidth((int) image3Width); imageView4.setImageDrawable(image4); imageView4.setAdjustViewBounds(true); imageView4.setMaxHeight((int) image4Height); imageView4.setMaxWidth((int) image4Width); setOrientation(LinearLayout.HORIZONTAL); setBackgroundColor(0x8800CCCC); param1 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); param1.gravity = Gravity.CENTER_VERTICAL; param1.weight = 1; addView(imageView1, param1); param2 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); param2.gravity = Gravity.CENTER_VERTICAL; param2.weight = 1; addView(imageView2, param2); param3 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); param3.gravity = Gravity.CENTER_VERTICAL; param3.weight = 1; addView(imageView3, param3); param4 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); param4.gravity = Gravity.CENTER_VERTICAL; param4.weight = 1; addView(imageView4, param4); imageView1.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { listener.Click1(); } }); imageView2.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { listener.Click2(); } }); imageView3.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { listener.Click3(); } }); imageView4.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { listener.Click4(); } }); }
private void initContent(Context context) { Log.i("coder", "-----initContent----"); // 设置水平方向 setOrientation(HORIZONTAL); setGravity(Gravity.CENTER_VERTICAL); // 设置背景 setBackgroundResource(R.drawable.ic_title_bg); // Context context = getContext(); btn_left = new Button(context); btn_left.setVisibility(View.INVISIBLE); // 设置设置不可见 if (left_drawable != 0) { btn_left.setBackgroundResource(left_drawable); } else { btn_left.setBackgroundResource(R.drawable.button_back); // 设置背景 } btn_left.setTextColor(fontColor); // 字体颜色 // btn_left.setTextAppearance(context, android.R.attr.textAppearanceSmall); if (null != strBtnLeft) { LayoutParams btnLeftParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); btnLeftParams.setMargins(10, 0, 0, 0); btn_left.setLayoutParams(btnLeftParams); btn_left.setText(strBtnLeft); btn_left.setVisibility(View.VISIBLE); } else { btn_left.setLayoutParams(new LayoutParams(50, 50)); } btn_left.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize_btn); // 添加这个按钮 addView(btn_left); // tv_title = new TextView(context); LayoutParams centerParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); centerParam.weight = 1; tv_title.setLayoutParams(centerParam); tv_title.setTextColor(fontColor); // tv_title.setTextAppearance(context, android.R.style.TextAppearance_DeviceDefault_Medium); tv_title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize_title); if (null != strTitle) { tv_title.setText(strTitle); } tv_title.setGravity(Gravity.CENTER); btn_left.setVisibility(View.VISIBLE); // 添加这个标题 addView(tv_title); btn_right = new Button(context); btn_right.setVisibility(View.INVISIBLE); // 设置设置不可见 btn_right.setBackgroundResource(R.drawable.button_next); // 设置背景 btn_right.setTextColor(fontColor); // 字体颜色 btn_right.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize_btn); // btn_right.setTextAppearance(context, android.R.attr.textAppearanceSmall); if (right_drawable != 0) { btn_right.setBackgroundResource(right_drawable); } else { btn_right.setBackgroundResource(R.drawable.button_next); // 设置背景 } if (null != strBtnRight) { LayoutParams btnRightParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); btnRightParams.setMargins(0, 0, 10, 0); btn_right.setLayoutParams(btnRightParams); btn_right.setText(strBtnRight); btn_right.setVisibility(View.VISIBLE); } else { btn_right.setLayoutParams(new LayoutParams(50, 50)); } // 添加这个按钮 addView(btn_right); }
@SuppressWarnings("static-access") private void init() { this.setBackgroundResource(R.drawable.cs_recommend_bg); this.setOrientation(LinearLayout.VERTICAL); RelativeLayout contentLayout = new RelativeLayout(context); LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); contentLayout.setLayoutParams(layoutParams); this.addView(contentLayout); TextView titleTextView = new TextView(context); titleTextView.setText(R.string.download_manager); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 3); titleTextView.setTextColor(Color.WHITE); int titleMargin = 20; RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.leftMargin = titleMargin; titleParams.rightMargin = titleMargin; titleParams.topMargin = titleMargin; titleParams.bottomMargin = titleMargin; titleTextView.setLayoutParams(titleParams); contentLayout.addView(titleTextView); LinearLayout managerLayout = new LinearLayout(context); managerLayout.setId(MANAGERLAYOUT_ID); managerLayout.setOrientation(LinearLayout.VERTICAL); int managerPad = 10; managerLayout.setPadding(managerPad, managerPad, managerPad, managerPad); int height = DisplayManager.getInstance(context).getScreenHeight() - 150; int width = DisplayManager.getInstance(context).getScreenWidth() - 200; RelativeLayout.LayoutParams managerLayoutParams = new RelativeLayout.LayoutParams(width, height); managerLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); managerLayout.setLayoutParams(managerLayoutParams); managerLayout.setBackgroundResource(R.drawable.bg_downmanger_content); // managerLayout.setBackgroundColor(Color.parseColor("#99000000")); contentLayout.addView(managerLayout); LinearLayout managerPathLayout = new LinearLayout(context); managerPathLayout.setOrientation(LinearLayout.HORIZONTAL); LayoutParams managerPathParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50); managerPathLayout.setLayoutParams(managerPathParams); managerPathLayout.setPadding(managerPad, 0, managerPad, managerPad); TextView pathText = new TextView(context); pathText.setText(R.string.present_path); pathText.setGravity(Gravity.CENTER); pathText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3); LayoutParams pathTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3); pathText.setTextColor(Color.parseColor("#ffffff")); pathTextParams.setMargins(0, 0, 0, 0); pathTextParams.gravity = Gravity.CENTER; pathText.setLayoutParams(pathTextParams); managerPathLayout.addView(pathText); final CheckDownDialogView checkDialog = new CheckDownDialogView(context); String present_edit = ""; if (checkDialog.DetectionDisk() != null) { present_edit = checkDialog.getDownPathname(); } pathEdit = new EditText(context); pathEdit.setText(present_edit); pathEdit.setFocusable(false); pathEdit.setGravity(Gravity.CENTER_VERTICAL); pathEdit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3); LayoutParams pathEditParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 12); pathEdit.setTextColor(Color.parseColor("#ffffff")); pathEdit.setBackgroundResource(R.drawable.present_path); pathEditParams.gravity = Gravity.CENTER_VERTICAL; pathEdit.setLayoutParams(pathEditParams); managerPathLayout.addView(pathEdit); Button pathButton = new FocusAbleButton(context); pathButton.setText(R.string.present_sele); pathButton.setTextColor(Color.parseColor("#ffffff")); pathButton.setGravity(Gravity.CENTER); pathButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3); LayoutParams pathButtonViewParams = new LinearLayout.LayoutParams(0, layoutParams.WRAP_CONTENT, 2); pathButtonViewParams.gravity = Gravity.CENTER; pathButtonViewParams.setMargins(35, 0, 0, 0); pathButton.setLayoutParams(pathButtonViewParams); managerPathLayout.addView(pathButton); pathButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // Map<String, String> labMap = checkDialog.DetectionDisk(); List<String> pathsStr = DownloadResourceManager.getInstance().getFileDir(); if (pathsStr != null) { checkDialog.choiceUsbDialog(); checkDialog.setListener( new PathChoiceClickListener() { @Override public void onClick(View v) { // 下载进度保存 LinkedHashMap<String, FilmDownLoad4k> downStatus = DownloadResourceManager.getInstance().getDLStatus(); if (downStatus != null) { DownloadResourceManager.getInstance().writeDownStatus(downStatus); } DownloadResourceManager.getInstance().clearDLData(); String path = (String) v.getTag(); DownloadResourceManager.getInstance().initDownPath(path); // Log.e(dlStatus +" "+dlStatus.size()); if (context instanceof DownManagerActivity) { ((DownManagerActivity) context).setData(true); } String present_edit = checkDialog.getDownPathname(); pathEdit.setText(present_edit); // 初始化新路径后 检测U盘下载 更新UI // LinkedHashMap<String, FilmDownLoad4k> downStatu = // DownloadResourceManager.getInstance().getDLStatus(); // String path_dir = // DownloadResourceManager.getInstance().getDownLoadPath(); // if(downStatu != null){ // if((path+"/voole_video").equalsIgnoreCase(path_dir)){ // File downPath = new File(path_dir); // if (TextUtils.isEmpty(DownloadResourceManager.getInstance() // .getDownLoadPath()) // || !downPath.getParentFile().exists() || !downPath.exists()){ // if(clickNum == 0){ // managerAct.updateDownItem(); // } // clickNum ++; // } if (context instanceof DownManagerActivity) { if (!((DownManagerActivity) context).isAlive) { // 如果下载线程停止 ((DownManagerActivity) context).setData(true); // 存放数据 ((DownManagerActivity) context).updateDownItem(); // 启动下载线程 } } } }); } else { // 没插入U盘 TVAlertDialog tvDialog = new TVAlertDialog(context); tvDialog.showInspectDialog(context); } } }); LayoutParams parmsPath = new LayoutParams(LayoutParams.MATCH_PARENT, 0); parmsPath.weight = 1; parmsPath.topMargin = 20; parmsPath.leftMargin = 40; parmsPath.rightMargin = 90; managerLayout.addView(managerPathLayout, parmsPath); LinearLayout managerTitleLayout = new LinearLayout(context); managerTitleLayout.setOrientation(LinearLayout.HORIZONTAL); managerTitleLayout.setBackgroundResource(R.drawable.bg_down_title); LayoutParams managerTitleLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50); managerTitleLayout.setLayoutParams(managerTitleLayoutParams); managerTitleLayout.setPadding(managerPad, managerPad - 4, managerPad, managerPad + 4); TextView nameText = new TextView(context); nameText.setText(R.string.filename); nameText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams nameTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3); nameText.setTextColor(Color.parseColor("#d5ac84")); nameText.setGravity(Gravity.CENTER); nameText.setLayoutParams(nameTextParams); managerTitleLayout.addView(nameText); TextView progressText = new TextView(context); LayoutParams progressTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4); progressText.setText(R.string.progress); progressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); progressText.setTextColor(Color.parseColor("#d5ac84")); progressText.setGravity(Gravity.CENTER); progressText.setLayoutParams(progressTextParams); managerTitleLayout.addView(progressText); TextView speedText = new TextView(context); speedText.setText(R.string.speed); speedText.setTextColor(Color.parseColor("#d5ac84")); speedText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams speedTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2); speedText.setGravity(Gravity.CENTER); speedText.setLayoutParams(speedTextParams); managerTitleLayout.addView(speedText); TextView sizeText = new TextView(context); sizeText.setText(R.string.size); sizeText.setTextColor(Color.parseColor("#d5ac84")); sizeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams sizeTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1); sizeText.setGravity(Gravity.CENTER); sizeText.setLayoutParams(sizeTextParams); managerTitleLayout.addView(sizeText); TextView handleText = new TextView(context); handleText.setText(R.string.operation); handleText.setTextColor(Color.parseColor("#d5ac84")); handleText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams handleTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2); handleText.setGravity(Gravity.CENTER); handleText.setLayoutParams(handleTextParams); managerTitleLayout.addView(handleText); LayoutParams parms = new LayoutParams(LayoutParams.MATCH_PARENT, 0); parms.weight = 1; parms.leftMargin = 30; parms.rightMargin = 30; parms.topMargin = managerPad - 5; managerLayout.addView(managerTitleLayout, parms); adapterLinearLayout = new FilmLinearLayout(context); LayoutParams adapterLinearLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0); adapterLinearLayoutParams.weight = 6; managerLayout.addView(adapterLinearLayout, adapterLinearLayoutParams); adapterLinearLayout.setId(FilmLinearLayout.ADAPTERLINEARLAYOUT_ID); int pading = 20; LinearLayout pageIndexLayout = new LinearLayout(context); pageIndexLayout.setOrientation(LinearLayout.HORIZONTAL); LayoutParams pageIndexLayoutLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); pageIndexLayout.setLayoutParams(pageIndexLayoutLayoutParams); pageIndexLayoutLayoutParams.setMargins(0, pading, 0, 0); pageIndexLayout.setGravity(Gravity.CENTER); Button preButton = new FocusAbleButton(context); preButton.setText(R.string.pre_page); preButton.setTextColor(Color.WHITE); preButton.setGravity(Gravity.CENTER); preButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams preButtonViewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); preButton.setLayoutParams(preButtonViewParams); pageIndexLayout.addView(preButton); preButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { adapterLinearLayout.showPrePage(); pageIndexTextview.setText( adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage()); } }); preButton.setPadding(pading, 0, pading, 0); Button nextButton = new FocusAbleButton(context); nextButton.setText(R.string.next_page); nextButton.setTextColor(Color.WHITE); nextButton.setGravity(Gravity.CENTER); nextButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams nextButtonViewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); nextButtonViewParams.leftMargin = textSize - 5; nextButton.setLayoutParams(nextButtonViewParams); pageIndexLayout.addView(nextButton); nextButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { adapterLinearLayout.showNextPage(); pageIndexTextview.setText( adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage()); } }); nextButton.setPadding(pading, 0, pading, 0); pageIndexTextview = new TextView(context); pageIndexTextview.setText( adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage()); pageIndexTextview.setTextColor(Color.WHITE); pageIndexTextview.setGravity(Gravity.CENTER); pageIndexTextview.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); LayoutParams pageIndexTextviewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); pageIndexTextviewParams.leftMargin = textSize - 5; pageIndexTextview.setLayoutParams(pageIndexTextviewParams); pageIndexLayout.addView(pageIndexTextview); LayoutParams pageIndexLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0); pageIndexLayoutParams.weight = 1; managerLayout.addView(pageIndexLayout, pageIndexLayoutParams); TextView warnInfoTextView = new TextView(getContext()); warnInfoTextView.setText(R.string.down_manager_warn_info); warnInfoTextView.setTextColor(Color.WHITE); warnInfoTextView.setGravity(Gravity.CENTER); warnInfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize); android.widget.RelativeLayout.LayoutParams warnInfoLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); warnInfoLayoutParams.addRule(RelativeLayout.BELOW, MANAGERLAYOUT_ID); warnInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, MANAGERLAYOUT_ID); warnInfoLayoutParams.topMargin = textSize - 10; contentLayout.addView(warnInfoTextView, warnInfoLayoutParams); }