// page body private LinearLayout getPageBody() { llBody = new LinearLayout(getContext()); llBody.setId(2); int resId = getBitmapRes(activity, "edittext_back"); if (resId > 0) { llBody.setBackgroundResource(resId); } llBody.setOrientation(LinearLayout.VERTICAL); RelativeLayout.LayoutParams lpBody = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId()); lpBody.addRule(RelativeLayout.BELOW, llTitle.getId()); lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId()); if (!dialogMode) { lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); } int dp_3 = dipToPx(getContext(), 3); lpBody.setMargins(dp_3, dp_3, dp_3, dp_3); llBody.setLayoutParams(lpBody); llBody.addView(getMainBody()); llBody.addView(getSep()); llBody.addView(getPlatformList()); return llBody; }
private void createView() { // Linear Layout LinearLayout linearLayout = new LinearLayout(this); linearLayout.setId(1); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setBackgroundColor(Color.BLACK); this.setContentView(linearLayout); // Relative Layout RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setId(2); relativeLayout.setGravity(Gravity.CENTER); relativeLayout.setBackgroundColor(Color.BLACK); RelativeLayout.LayoutParams relativeLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); relativeLayout.setLayoutParams(relativeLayoutParams); linearLayout.addView(relativeLayout); // Video View videoView = new VideoView(this); videoView.setId(3); RelativeLayout.LayoutParams videoViewParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); videoViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); videoView.setLayoutParams(videoViewParams); relativeLayout.addView(videoView); }
@Override protected void onPrepareDialogBuilder(Builder builder) { super.onPrepareDialogBuilder(builder); OnColorChangedListener l = new OnColorChangedListener() { public void colorChanged(int color) { mCurrentColor = color; onDialogClosed(true); getDialog().dismiss(); } }; LinearLayout layout = new LinearLayout(getContext()); layout.setPadding(20, 20, 20, 20); layout.setOrientation(LinearLayout.VERTICAL); mCPView = new ColorPickerView(getContext(), l, mCurrentColor); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params1.gravity = Gravity.CENTER; mCPView.setLayoutParams(params1); layout.addView(this.mCPView); layout.setId(android.R.id.widget_frame); builder.setView(layout); }
/** * Provide default implementation to return a simple list view. Subclasses can override to replace * with their own layout. If doing so, the returned view hierarchy <em>must</em> have a * ExpandableListView whose id is {@link android.R.id#list android.R.id.list} and can optionally * have a sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when * the list is empty. * * <p>If you are overriding this method with your own custom content, consider including the * standard layout {@link android.R.layout#list_content} in your layout file, so that you continue * to retain all of the standard behavior of ListFragment. In particular, this is currently the * only way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = getActivity(); FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView( progress, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView( pframe, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView( tv, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); ExpandableListView lv = new ExpandableListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView( lv, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); root.addView( lframe, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); return root; }
/** * creates a linear layout the contains only a textview. (non-Javadoc) * * @see android.preference.Preference#onCreateView(android.view.ViewGroup) * @param parent * @return * @author ricky barrette */ @Override protected View onCreateView(final ViewGroup parent) { /* * create a vertical linear layout that width and height that wraps * content */ final LinearLayout layout = new LinearLayout(getContext()); final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; layout.setPadding(15, 5, 10, 5); layout.setOrientation(LinearLayout.VERTICAL); layout.removeAllViews(); /* * create a textview that will be used to display the title provided in * xml and add it to the lay out */ final TextView title = new TextView(getContext()); title.setText(getTitle()); title.setTextSize(16); title.setTypeface(Typeface.SANS_SERIF); title.setGravity(Gravity.LEFT); title.setLayoutParams(params); /* * add the title and the time picker views to the layout */ layout.addView(title); layout.setId(android.R.id.widget_frame); return layout; }
@Override protected View onCreateView(ViewGroup parent) { LinearLayout layout = new LinearLayout(getContext()); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); // params1.gravity = Gravity.LEFT; params1.weight = 1.0f; layout.setPadding(15, 10, 10, 10); layout.setOrientation(LinearLayout.HORIZONTAL); TextView view = new TextView(getContext()); view.setText(R.string.rerun_setup_wizard); // view.setTextSize(18); // view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); view.setTextAppearance(getContext(), android.R.style.TextAppearance_Large); // view.setGravity(Gravity.LEFT); view.setLayoutParams(params1); this.setOnPreferenceClickListener( new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference arg0) { getContext().startActivity(new Intent(getContext(), WizardActivity.class)); return true; } }); layout.addView(view); layout.setId(android.R.id.widget_frame); return layout; }
@Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout ll; SpinnerRes res = getItem(position); if (convertView == null) { ll = new LinearLayout(context); ll.setOnClickListener(spinner); View v = createItemView(_layoutInflater, position, null, parent, res); if (v != null) { ll.addView(v); } } else { ll = (LinearLayout) convertView; createItemView(_layoutInflater, position, ll.getChildAt(0), parent, res); } ll.setId(ITEM_ID); ll.setTag(position + ""); if (getItem(position).isDefSelected()) { ll.setBackgroundResource(selectedBackground); selectedIndex = position; spinner.setText(getItem(position).getValue()); } else { ll.setBackgroundResource(childBackground); } return ll; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout view = new LinearLayout(this); view.setId(1); setContentView(view); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); characters = new ArrayList<CharTextView>(); mainLayout = new LinearLayout(this); setContentView(mainLayout); mainLayout.setOrientation(LinearLayout.VERTICAL); mainLayout.setId(442); grid = new GridLayout(this); GridLayout.LayoutParams gridParams = new GridLayout.LayoutParams(GridLayout.spec(3), GridLayout.spec(7)); grid.setId(444); int counter = 0; for (int i = 0; i < 7; ++i) { for (int j = 0; j < 2; ++j) { CharTextView iv = new CharTextView(this); Bitmap joeAvatar = BitmapFactory.decodeResource(getResources(), R.drawable.joe); Character joe = new Character(joeAvatar, "Joe Nash", 24, "United Kingdom"); iv.setCharacterCell(joe); iv.setId(50 + counter); GridLayout.LayoutParams buttonparams = new GridLayout.LayoutParams(GridLayout.spec(j), GridLayout.spec(i)); buttonparams.height = 200; buttonparams.width = 150; iv.setOnClickListener(this); grid.addView(iv, buttonparams); characters.add(iv); counter++; } } heroLayout = new FrameLayout(this); heroLayout.setId(443); FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); frameParams.height = 600; ImageView portrait = new ImageView(this); portrait.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.joenash)); heroLayout.addView(portrait); Button fightButton = new Button(this); fightButton.setText(R.string.fight); ViewGroup.LayoutParams buttonParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); buttonParams.height = 150; buttonParams.width = 650; mainLayout.addView(heroLayout, frameParams); mainLayout.addView(grid, gridParams); mainLayout.addView(fightButton, buttonParams); // znameto // heroLayout.setBackground(); // String variable = "variable" // int Button = getResources().getIdentifier(variable, "drawable", getPackageName()); }
/** Create the view in which the video will be rendered. */ private void setupView() { LinearLayout lLinLayout = new LinearLayout(this); lLinLayout.setId(1); lLinLayout.setOrientation(LinearLayout.VERTICAL); lLinLayout.setGravity(Gravity.CENTER); lLinLayout.setBackgroundColor(Color.BLACK); LayoutParams lLinLayoutParms = new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lLinLayout.setLayoutParams(lLinLayoutParms); this.setContentView(lLinLayout); RelativeLayout lRelLayout = new RelativeLayout(this); lRelLayout.setId(2); lRelLayout.setGravity(Gravity.CENTER); lRelLayout.setBackgroundColor(Color.BLACK); android.widget.RelativeLayout.LayoutParams lRelLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); lRelLayout.setLayoutParams(lRelLayoutParms); lLinLayout.addView(lRelLayout); mVideoView = new VideoView(this); mVideoView.setId(3); android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lVidViewLayoutParams); lRelLayout.addView(mVideoView); mProgressBar = new ProgressBar(this); mProgressBar.setIndeterminate(true); mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setEnabled(true); mProgressBar.setId(4); android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT); mProgressBar.setLayoutParams(lProgressBarLayoutParms); lRelLayout.addView(mProgressBar); mProgressMessage = new TextView(this); mProgressMessage.setId(5); android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms = new android.widget.RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL); lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4); mProgressMessage.setLayoutParams(lProgressMsgLayoutParms); mProgressMessage.setTextColor(Color.LTGRAY); mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); mProgressMessage.setText("..."); lRelLayout.addView(mProgressMessage); }
protected LinearLayout addIncludedView(int includedRootId, int stringResId) { LinearLayout container = new LinearLayout(this); container.setId(includedRootId); TextView textView = new TextView(this); container.addView(textView); textView.setId(android.R.id.text2); textView.setText(stringResId); return container; }
private RelativeLayout createAndFillDataMovementLayout(RestaurantDao restaurant, int position) { RelativeLayout relativeMovementLayout = (RelativeLayout) inflater.inflate(R.layout.restaurant_data, null, false); RelativeLayout relativeMovementInfoLayout = (RelativeLayout) relativeMovementLayout.findViewById(R.id.restaurant_data_info_layout); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_name)) .setText(restaurant.getRetaurantName()); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_direction)) .setText(restaurant.getRestaurantDisplayDirection()); String foodType = getFoodType(restaurant); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_type)) .setText(foodType); ((TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_phone)) .setText(restaurant.getPhoneNumber()); LinearLayout buttonsLayout = (LinearLayout) relativeMovementLayout.findViewById(R.id.restaurant_data_apps_layout); buttonsLayout.setId(position); if (wazeInstalled) { ImageButton wazeButton = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_waze_image); wazeButton.setVisibility(View.VISIBLE); wazeButton.setOnTouchListener(new TouchElementsListener<ImageButton>()); wazeButton.setOnClickListener(new WazeClickListener(restaurant)); } if (gNavigationInstalled) { ImageButton gNavigationButton = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_nav_image); gNavigationButton.setVisibility(View.VISIBLE); gNavigationButton.setOnTouchListener(new TouchElementsListener<ImageButton>()); gNavigationButton.setOnClickListener(new GNavClickListener(restaurant)); } TextView restaurantDataClose = (TextView) relativeMovementInfoLayout.findViewById(R.id.restaurant_data_close); restaurantDataClose.setOnClickListener( new OnClickListener() { public void onClick(View v) { dialog.hide(); dialog.cancel(); } }); ImageButton iButtonMaps = (ImageButton) buttonsLayout.findViewById(R.id.restaurant_data_maps); iButtonMaps.setOnTouchListener(new TouchElementsListener<ImageButton>()); iButtonMaps.setOnClickListener(new GMapsClickListener(restaurant)); return relativeMovementLayout; }
private void displayCall(Resources resources, LinphoneCall call, int index) { String sipUri = call.getRemoteAddress().asStringUriOnly(); LinphoneAddress lAddress; try { lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri); } catch (LinphoneCoreException e) { Log.e("Incall activity cannot parse remote address", e); lAddress = LinphoneCoreFactory.instance().createLinphoneAddress("uknown", "unknown", "unkonown"); } // Control Row LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false); callView.setId(index + 1); setContactName(callView, lAddress, sipUri, resources); displayCallStatusIconAndReturnCallPaused(callView, call); setRowBackground(callView, index); registerCallDurationTimer(callView, call); callsList.addView(callView); // Image Row LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false); Contact contact = ContactsManager.getInstance() .findContactWithAddress(imageView.getContext().getContentResolver(), lAddress); if (contact != null) { displayOrHideContactPicture( imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false); } else { displayOrHideContactPicture(imageView, null, null, false); } callsList.addView(imageView); callView.setTag(imageView); callView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (v.getTag() != null) { View imageView = (View) v.getTag(); if (imageView.getVisibility() == View.VISIBLE) imageView.setVisibility(View.GONE); else imageView.setVisibility(View.VISIBLE); callsList.invalidate(); } } }); }
@Override public View createContainer(int id) { LinearLayout container = id == CONTENT_CONTAINER_ID ? new SlideContent(getContext()) : new LinearLayout(getContext()); container.setId(id); container.setOrientation(LinearLayout.VERTICAL); LayoutParams params = new LayoutParams(-1, -1); if (MENU_CONTAINER_ID == id) params = new LayoutParams(Util.diptoPx(getContext(), 250), -1); // important :if didn't set this rule,rightMargin will be useless else params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); container.setLayoutParams(params); return container; }
private void addItem(SwipeMenuItem item, int id) { LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight()); LinearLayout parent = new LinearLayout(getContext()); parent.setId(id); parent.setGravity(Gravity.CENTER); parent.setOrientation(LinearLayout.VERTICAL); parent.setLayoutParams(params); parent.setBackgroundDrawable(item.getBackground()); parent.setOnClickListener(this); addView(parent); if (item.getIcon() != null) { parent.addView(createIcon(item)); } if (!TextUtils.isEmpty(item.getTitle())) { parent.addView(createTitle(item)); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout la = new LinearLayout(this); setContentView(la); TextView tv = new TextView(this); tv.setText("main"); la.addView(tv); LinearLayout laFrag = new LinearLayout(this); laFrag.setId(62546523); la.addView(laFrag); FragmentTransaction trFragments = getFragmentManager().beginTransaction(); Main10Frag1 frag = new Main10Frag1(); trFragments.add(laFrag.getId(), frag); trFragments.commit(); }
/** * createLinearLayout() creates the linear layout with EditText and Spinner views. * * @param hintTxt * @param optionList * @return LinearLayout */ public LinearLayout createLinearLayout(String hintTxt, List<String> optionList) { LinearLayout linLayout = new LinearLayout(mContext); // creating LinearLayout linLayout.setOrientation(LinearLayout.HORIZONTAL); // specifying horizontal orientation linLayout.setId(LINEAR_LAYOUT_ID); // set id linLayout.setBackgroundColor(Color.parseColor("#FFFFFF")); // set background color // Add EditText LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); EditText edtTxt = new EditText(mContext); edtTxt.setHint(hintTxt); edtTxt.setBackgroundColor(Color.WHITE); edtTxt.setLayoutParams(lpView); linLayout.addView(edtTxt); // Add Spinner Spinner spinner = new Spinner(mContext); setSpinner(spinner, optionList); linLayout.addView(spinner); // return the linearLayout return linLayout; }
public View getView(int i, View view, ViewGroup viewgroup) { if (view == null) { view = View.inflate(context, 0x7f030026, null); view.setOnClickListener(ocl); } crFacturas.moveToPosition(i); LinearLayout linearlayout = (LinearLayout) view; linearlayout.setId(crFacturas.getId()); linearlayout.setTag(crFacturas.getDocumento()); TextView textview = (TextView) linearlayout.findViewById(0x7f060075); Object aobj[] = new Object[1]; aobj[0] = crFacturas.getDocumento(); textview.setText(String.format("Factura: %s", aobj)); TextView textview1 = (TextView) linearlayout.findViewById(0x7f060068); Object aobj1[] = new Object[1]; aobj1[0] = crFacturas.getNombreCliente(); textview1.setText(String.format("Cliente: %s", aobj1)); ((TextView) linearlayout.findViewById(0x7f060074)).setText(crFacturas.getFecha()); TextView textview2 = (TextView) linearlayout.findViewById(0x7f060076); Object aobj2[] = new Object[1]; aobj2[0] = Double.valueOf(crFacturas.getMontoFacturado()); textview2.setText(String.format("Total Facturado: %.2f", aobj2)); return view; }
public View getAdapterView( final Context context, final AdInfo adInfo, int itemWidth, int itemHeight) { // 对小屏手机进行屏幕判断 int displaySize = SDKUtils.getDisplaySize(context); // 整体布局 RelativeLayout whole_layout = null; GradientDrawable click_bg_grad = new GradientDrawable( Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#FFD700"), Color.parseColor("#FFB90F"), Color.parseColor("#FFD700") }); // 广告数据布局 RelativeLayout r_layout = null; try { whole_layout = new RelativeLayout(context); if (itemWidth == 0 || itemHeight == 0) { itemWidth = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth(); // item的默认高度 if (displaySize == 320) { itemHeight = 55; } else if (displaySize == 240) { itemHeight = 40; } else if (displaySize == 720) { itemHeight = 120; } else if (displaySize == 1080) { itemHeight = 180; } else { itemHeight = 100; } } whole_layout.setLayoutParams(new ListView.LayoutParams(itemWidth, itemHeight)); r_layout = new RelativeLayout(context); int item_whole_bg_id = context.getResources().getIdentifier("item_bg", "drawable", context.getPackageName()); if (item_whole_bg_id != 0) { r_layout.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); r_layout.setBackgroundResource(item_whole_bg_id); } // r_layout.setPadding(0, 0, 0, 0); // 图标 ImageView app_icon = new ImageView(context); app_icon.setId(1); app_icon.setScaleType(ImageView.ScaleType.FIT_CENTER); app_icon.setImageDrawable(new BitmapDrawable(adInfo.getAdIcon())); app_icon.setPadding(5, 5, 5, 5); RelativeLayout.LayoutParams icon_img_params = null; if (displaySize == 320) { app_icon.setPadding(4, 4, 4, 4); icon_img_params = new RelativeLayout.LayoutParams(50, 50); } else if (displaySize == 240) { app_icon.setPadding(2, 2, 2, 2); icon_img_params = new RelativeLayout.LayoutParams(36, 36); } else if (displaySize == 720) { app_icon.setPadding(8, 8, 8, 8); icon_img_params = new RelativeLayout.LayoutParams(100, 100); } else if (displaySize == 1080) { app_icon.setPadding(10, 10, 10, 10); icon_img_params = new RelativeLayout.LayoutParams(140, 140); } else { app_icon.setPadding(5, 5, 5, 5); icon_img_params = new RelativeLayout.LayoutParams(75, 75); } icon_img_params.addRule(RelativeLayout.CENTER_VERTICAL); icon_img_params.leftMargin = 5; // 加载所有文字内容的整体布局 LinearLayout layout = new LinearLayout(context); layout.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setOrientation(LinearLayout.VERTICAL); int item_text_bg_id = context .getResources() .getIdentifier("item_text_bg", "drawable", context.getPackageName()); if (item_text_bg_id != 0) { // layout.setBackgroundResource(item_text_bg_id); } layout.setId(2); // 加载广告名称和广告大小的布局 RelativeLayout title_size_layout = new RelativeLayout(context); // 广告名称 TextView app_name = new TextView(context); app_name.setId(2); app_name.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); app_name.setText(adInfo.getAdName()); app_name.setTextSize(18); app_name.setTextColor(Color.BLACK); app_name.setPadding(10, 0, 0, 0); // 广告大小 TextView app_size = new TextView(context); app_size.setText(adInfo.getFilesize() + "M"); app_size.setTextSize(12); app_size.setTextColor(Color.GRAY); app_size.setPadding(5, 0, 5, 0); RelativeLayout.LayoutParams params4 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params4.addRule(RelativeLayout.ALIGN_TOP, app_name.getId()); params4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); title_size_layout.addView(app_name); title_size_layout.addView(app_size, params4); // 广告语 TextView content = new TextView(context); content.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); content.setText(adInfo.getAdText()); content.setPadding(10, 0, 0, 0); content.setTextColor(Color.GRAY); layout.addView(title_size_layout); layout.addView(content); // 下载按钮 LinearLayout down_layout = new LinearLayout(context); down_layout.setOrientation(LinearLayout.HORIZONTAL); down_layout.setGravity(Gravity.CENTER); down_layout.setId(3); // 直接加载下载图标的布局 RelativeLayout down_img_layout = new RelativeLayout(context); int down_layout_width = 75; if (displaySize == 320) { down_layout_width = 45; } else if (displaySize == 240) { down_layout_width = 30; } else if (displaySize == 720) { down_layout_width = 100; } else if (displaySize == 1080) { down_layout_width = 150; } down_img_layout.setLayoutParams( new LinearLayout.LayoutParams(down_layout_width, LayoutParams.FILL_PARENT)); ImageView downImage = new ImageView(context); int down_bg_id = context.getResources().getIdentifier("down_ico", "drawable", context.getPackageName()); if (down_bg_id != 0) { downImage.setImageResource(down_bg_id); } // 下载按钮的点击半透明遮罩效果布局 final LinearLayout d_layout = new LinearLayout(context); d_layout.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // d_layout.setBackgroundColor(Color.argb(80, 0, 0, 0)); // d_layout.setBackgroundColor(Color.parseColor("#AAFFD700")); d_layout.setBackgroundDrawable(click_bg_grad); d_layout.setVisibility(View.INVISIBLE); RelativeLayout.LayoutParams down_img_params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); down_img_params.addRule(RelativeLayout.CENTER_IN_PARENT); down_img_layout.addView(d_layout); down_img_layout.addView(downImage, down_img_params); // 竖直分隔线 int line_size = 4; if (displaySize == 240) { line_size = 2; } LinearLayout line_layout_2 = new LinearLayout(context); line_layout_2.setLayoutParams( new LinearLayout.LayoutParams(line_size, LayoutParams.FILL_PARENT)); // 颜色渐变 GradientDrawable grad = new GradientDrawable( Orientation.LEFT_RIGHT, new int[] { Color.parseColor("#cccccc"), Color.parseColor("#ffffff"), Color.parseColor("#cccccc") }); line_layout_2.setBackgroundDrawable(grad); down_layout.addView(line_layout_2); down_layout.addView(down_img_layout); down_img_layout.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { // 点击时,ListView的item产生被点击效果(半透明遮罩) case MotionEvent.ACTION_DOWN: d_layout.setVisibility(View.VISIBLE); break; // 离开点击区域,ListView的item点击效果消失 case MotionEvent.ACTION_CANCEL: d_layout.setVisibility(View.INVISIBLE); break; // 点击后抬起时,ListView的item点击效果消失 case MotionEvent.ACTION_UP: d_layout.setVisibility(View.INVISIBLE); break; } return false; } }); down_img_layout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId()); } }); RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); params2.addRule(RelativeLayout.RIGHT_OF, app_icon.getId()); params2.addRule(RelativeLayout.LEFT_OF, down_layout.getId()); params2.addRule(RelativeLayout.CENTER_VERTICAL); RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); // params3.addRule(RelativeLayout.RIGHT_OF, layout.getId()); params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // int width = ((Activity)context).getWindowManager().getDefaultDisplay().getWidth()-83; // 点击效果的半透明遮罩布局 final LinearLayout l_layout = new LinearLayout(context); l_layout.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // l_layout.setBackgroundColor(Color.argb(80, 0, 0, 0));//黑色 // l_layout.setBackgroundColor(Color.argb(80, 30, 144, 255));//淡蓝色 // l_layout.setBackgroundColor(Color.parseColor("#AAFFD700")); l_layout.setBackgroundDrawable(click_bg_grad); l_layout.setVisibility(View.INVISIBLE); r_layout.addView(l_layout); r_layout.addView(app_icon, icon_img_params); r_layout.addView(down_layout, params3); r_layout.addView(layout, params2); whole_layout.addView(r_layout); r_layout.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { // 点击时,ListView的item产生被点击效果(半透明遮罩) case MotionEvent.ACTION_DOWN: l_layout.setVisibility(View.VISIBLE); break; // 离开点击区域,ListView的item点击效果消失 case MotionEvent.ACTION_CANCEL: l_layout.setVisibility(View.INVISIBLE); break; // 点击后抬起时,ListView的item点击效果消失 case MotionEvent.ACTION_UP: l_layout.setVisibility(View.INVISIBLE); break; } return false; } }); r_layout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { AppDetail.getInstanct().showAdDetail(context, adInfo); } }); } catch (Exception e) { e.printStackTrace(); } return whole_layout; }
/** * Generates match tables of the currently active tournament * * @param roundNumber Current round number */ public void createMatchTable(int roundNumber) { rounds = tournament.getRounds(); Log.d("ScoresFragment", rounds[0].getGames()[0].getAwayPlayer().getName()); Game[] games = rounds[roundNumber - 1].getGames(); LinearLayout linearContainerTop = new LinearLayout(getActivity().getBaseContext()); LinearLayout.LayoutParams paramsContainerTop = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearContainerTop.setLayoutParams(paramsContainerTop); containerId = containerId + multiplier; containerIDs.add(containerId); linearContainerTop.setId(containerId); linearContainerTop.setBackgroundColor(getResources().getColor(R.color.darkgray)); linearContainerTop.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < games.length; i++) { int id = i; Player homePlayer = games[i].getHomePlayer(); Player awayPlayer = games[i].getAwayPlayer(); LinearLayout linearContainer = new LinearLayout(getActivity().getBaseContext()); LinearLayout.LayoutParams paramsContainer = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); linearContainer.setLayoutParams(paramsContainer); linearContainer.setId(6); linearContainer.setBackgroundColor(getResources().getColor(R.color.darkgray)); linearContainer.setOrientation(LinearLayout.HORIZONTAL); TextView homeText = new TextView(getActivity().getBaseContext()); homeText.setId(1); LinearLayout.LayoutParams paramsHomeText = new LinearLayout.LayoutParams(0, 130, 0.5f); homeText.setGravity(Gravity.CENTER); paramsHomeText.setMargins(10, 10, 10, 0); homeText.setLayoutParams(paramsHomeText); homeText.setText(homePlayer.getName()); homeText.setTextSize(18); TextView midText = new TextView(getActivity().getBaseContext()); LinearLayout.LayoutParams paramsMidText = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.1f); paramsMidText.setMargins(10, 10, 10, 0); midText.setGravity(Gravity.CENTER); midText.setLayoutParams(paramsMidText); midText.setId(3); midText.setText("-"); LinearLayout.LayoutParams paramsAwayText = new LinearLayout.LayoutParams(0, 130, 0.5f); TextView awayText = new TextView(getActivity().getBaseContext()); awayText.setId(2); awayText.setText(awayPlayer.getName()); awayText.setTextSize(18); paramsAwayText.setMargins(10, 10, 10, 0); awayText.setLayoutParams(paramsAwayText); awayText.setGravity(Gravity.CENTER); EditText homeScore = new EditText(getActivity().getBaseContext()); homeScoreId = homeScoreId + multiplier; homeScoreIDs.add(homeScoreId); LinearLayout.LayoutParams paramsHomeScore = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f); homeScore.setGravity(Gravity.CENTER); paramsHomeScore.setMargins(10, 10, 10, 0); homeScore.setLayoutParams(paramsHomeScore); homeScore.setText(Integer.toString(games[i].getHomeScore())); homeScore.setInputType(InputType.TYPE_CLASS_NUMBER); homeScore.setId(homeScoreId); EditText awayScore = new EditText(getActivity().getBaseContext()); awayScoreId = awayScoreId + multiplier; awayScoreIDs.add(awayScoreId); LinearLayout.LayoutParams paramsAwayScore = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.2f); awayScore.setGravity(Gravity.CENTER); paramsAwayScore.setMargins(10, 10, 10, 0); awayScore.setLayoutParams(paramsAwayScore); awayScore.setInputType(InputType.TYPE_CLASS_NUMBER); awayScore.setText(Integer.toString(games[i].getAwayScore())); awayScore.setId(awayScoreId); linearContainer.addView(homeText); linearContainer.addView(homeScore); linearContainer.addView(midText); linearContainer.addView(awayScore); linearContainer.addView(awayText); linearContainerTop.addView(linearContainer); } layout.addView(linearContainerTop); }
protected void onCreateContent(LinearLayout parent) { SizeHelper.prepare(context); LinearLayout rlCountry = new LinearLayout(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(96)); params.setMargins( SizeHelper.fromPx(26), SizeHelper.fromPxWidth(32), SizeHelper.fromPxWidth(26), 0); rlCountry.setLayoutParams(params); rlCountry.setId(Res.id.rl_country); TextView tv = new TextView(context); LinearLayout.LayoutParams tvParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tvParams.gravity = Gravity.CENTER_VERTICAL; tv.setLayoutParams(tvParams); tv.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0); int resid = R.getStringRes(context, "smssdk_country"); tv.setText(resid); tv.setTextColor(0xff000000); tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25)); rlCountry.addView(tv); TextView tvCountry = new TextView(context); tvCountry.setId(Res.id.tv_country); LinearLayout.LayoutParams tvCountryParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tvCountryParams.gravity = Gravity.CENTER_VERTICAL; tvCountryParams.weight = 1; tvCountryParams.rightMargin = SizeHelper.fromPxWidth(14); tvCountry.setLayoutParams(tvCountryParams); tvCountry.setGravity(Gravity.RIGHT); tvCountry.setPadding(SizeHelper.fromPxWidth(14), 0, SizeHelper.fromPxWidth(14), 0); tvCountry.setTextColor(0xff45c01a); tvCountry.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25)); rlCountry.addView(tvCountry); parent.addView(rlCountry); View line = new View(context); LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, SizeHelper.fromPxWidth(1)); lineParams.leftMargin = SizeHelper.fromPxWidth(26); lineParams.rightMargin = SizeHelper.fromPxWidth(26); line.setLayoutParams(lineParams); line.setBackgroundColor(Res.color.smssdk_gray_press); parent.addView(line); LinearLayout phoneLayout = new LinearLayout(context); LinearLayout.LayoutParams phoneParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(70)); phoneParams.setMargins( SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(30), SizeHelper.fromPxWidth(26), 0); phoneLayout.setLayoutParams(phoneParams); TextView countryNum = new TextView(context); countryNum.setId(Res.id.tv_country_num); LinearLayout.LayoutParams countryNumParams = new LinearLayout.LayoutParams( SizeHelper.fromPxWidth(104), LinearLayout.LayoutParams.MATCH_PARENT); countryNum.setLayoutParams(countryNumParams); countryNum.setGravity(Gravity.CENTER); countryNum.setTextColor(0xff353535); countryNum.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25)); resid = R.getBitmapRes(context, "smssdk_input_bg_focus"); countryNum.setBackgroundResource(resid); phoneLayout.addView(countryNum); LinearLayout wrapperLayout = new LinearLayout(context); LinearLayout.LayoutParams wrapperParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT); wrapperParams.weight = 1; wrapperLayout.setLayoutParams(wrapperParams); resid = R.getBitmapRes(context, "smssdk_input_bg_special_focus"); wrapperLayout.setBackgroundResource(resid); EditText writePhone = new EditText(context); writePhone.setId(Res.id.et_write_phone); LinearLayout.LayoutParams writePhoneParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT); writePhoneParams.gravity = Gravity.CENTER_VERTICAL; writePhoneParams.setMargins(SizeHelper.fromPxWidth(10), 0, SizeHelper.fromPxWidth(10), 0); writePhoneParams.weight = 1; writePhone.setLayoutParams(writePhoneParams); writePhone.setBackgroundDrawable(null); resid = R.getStringRes(context, "smssdk_write_mobile_phone"); writePhone.setHint(resid); writePhone.setInputType(InputType.TYPE_CLASS_PHONE); writePhone.setTextColor(0xff353535); writePhone.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25)); wrapperLayout.addView(writePhone); ImageView image = new ImageView(context); image.setId(Res.id.iv_clear); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(24), SizeHelper.fromPxWidth(24)); imageParams.gravity = Gravity.CENTER_VERTICAL; imageParams.rightMargin = SizeHelper.fromPxWidth(20); image.setLayoutParams(imageParams); resid = R.getBitmapRes(context, "smssdk_clear_search"); image.setBackgroundResource(resid); image.setScaleType(ScaleType.CENTER_INSIDE); image.setVisibility(View.GONE); wrapperLayout.addView(image); phoneLayout.addView(wrapperLayout); parent.addView(phoneLayout); Button nextBtn = new Button(context); nextBtn.setId(Res.id.btn_next); LinearLayout.LayoutParams nextParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, SizeHelper.fromPxWidth(72)); nextParams.setMargins( SizeHelper.fromPxWidth(26), SizeHelper.fromPxWidth(36), SizeHelper.fromPxWidth(26), 0); nextBtn.setLayoutParams(nextParams); resid = R.getBitmapRes(context, "smssdk_btn_disenable"); nextBtn.setBackgroundResource(resid); resid = R.getStringRes(context, "smssdk_next"); nextBtn.setText(resid); nextBtn.setTextColor(0xffffffff); nextBtn.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(25)); nextBtn.setPadding(0, 0, 0, 0); parent.addView(nextBtn); }
public void showAdDetail(final Context context, final AdInfo adInfo){ try { final Dialog dialog = new Dialog(context, android.R.style.Theme_Translucent); if(adInfo != null){ View view = View.inflate(context, context.getResources().getIdentifier("detail", "layout", context.getPackageName()), null); ImageView icon = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_icon", "id", context.getPackageName())); TextView title = (TextView) view.findViewById(context.getResources().getIdentifier("detail_title", "id", context.getPackageName())); TextView version = (TextView) view.findViewById(context.getResources().getIdentifier("detail_version", "id", context.getPackageName())); TextView filesize = (TextView) view.findViewById(context.getResources().getIdentifier("detail_filesize", "id", context.getPackageName())); Button downButton1 = (Button) view.findViewById(context.getResources().getIdentifier("detail_downButton1", "id", context.getPackageName())); TextView content = (TextView) view.findViewById(context.getResources().getIdentifier("detail_content", "id", context.getPackageName())); TextView description = (TextView) view.findViewById(context.getResources().getIdentifier("detail_description", "id", context.getPackageName())); ImageView image1 = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_image1", "id", context.getPackageName())); ImageView image2 = (ImageView) view.findViewById(context.getResources().getIdentifier("detail_image2", "id", context.getPackageName())); Button downButton2 = (Button) view.findViewById(context.getResources().getIdentifier("detail_downButton2", "id", context.getPackageName())); icon.setImageBitmap(adInfo.getAdIcon()); icon.setScaleType(ImageView.ScaleType.FIT_CENTER); title.setText(adInfo.getAdName()); title.setTextSize(17); version.setText(" "+adInfo.getVersion()); filesize.setText(" "+adInfo.getFilesize()+"M"); content.setText(adInfo.getAdText()); description.setText(adInfo.getDescription()); new GetImagesTask(context, adInfo, image1, image2).execute(); downButton1.setOnClickListener(new OnClickListener() { public void onClick(View v) { AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId()); if(dialog != null){ dialog.cancel(); } } }); downButton2.setOnClickListener(new OnClickListener() { public void onClick(View v) { AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId()); if(dialog != null){ dialog.cancel(); } } }); int bg_img = context.getResources().getIdentifier("detail_bg", "drawable", context.getPackageName()); if(bg_img != 0){ view.setBackgroundResource(bg_img); }else{ view.setBackgroundResource(android.R.drawable.editbox_background); } LinearLayout layout = new LinearLayout(context); layout.setGravity(Gravity.CENTER); layout.setId(1); // 对小屏手机进行屏幕判断 int displaySize = SDKUtils.getDisplaySize(context); if(displaySize == 320){ layout.setPadding(15, 15, 15, 15); }else if(displaySize == 240){ layout.setPadding(10, 10, 10, 10); }else{ layout.setPadding(20, 20, 20, 20); } layout.setBackgroundColor(Color.argb(200, 10, 10, 10)); layout.addView(view); dialog.setContentView(layout); dialog.show(); } } catch (Exception e) { e.printStackTrace(); AppConnect.getInstance(context).clickAd(context, adInfo.getAdId()); } }
@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); }
protected void createView() { Display display = this.getWindow().getWindowManager().getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT > 12) { display.getSize(size); } else { size.y = display.getHeight(); size.x = display.getWidth(); } int width_times = Math.round((float) size.x / (56.0f * density)); float dialog_width = ((float) (width_times - 1) * 56.0f * density); // add a view to margin the space LayoutParams mvParams = new LayoutParams((int) dialog_width, LayoutParams.WRAP_CONTENT); LinearLayout messageView = new LinearLayout(this.getContext()); messageView.setLayoutParams(mvParams); messageView.setPadding(view_padding, view_padding, view_padding, view_padding); messageView.setGravity(Gravity.TOP | Gravity.CENTER); messageView.setOrientation(LinearLayout.VERTICAL); // icon LayoutParams iconParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); iconParams.setMargins(0, 0, 0, view_margin); iconParams.gravity = Gravity.CENTER; ImageView icon = new ImageView(this.getContext()); icon.setLayoutParams(iconParams); icon.setId(android.R.id.icon); icon.setVisibility(View.GONE); // title LayoutParams titleParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); titleParams.setMargins(0, 0, 0, view_margin); TextView title = new TextView(this.getContext()); title.setLayoutParams(titleParams); title.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark)); title.setTextSize(20); title.setTypeface(null, Typeface.BOLD); title.setId(android.R.id.title); title.setVisibility(View.GONE); // message LayoutParams msgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); TextView message = new TextView(this.getContext()); message.setLayoutParams(msgParams); message.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark)); message.setTextSize(18); message.setId(android.R.id.message); message.setVisibility(View.GONE); // optional choice LayoutParams checkBoxParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); checkBoxParams.setMargins(0, view_margin, 0, 0); CheckBox checkBox = new CheckBox(this.getContext()); checkBox.setLayoutParams(checkBoxParams); checkBox.setId(android.R.id.checkbox); checkBox.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark)); checkBox.setVisibility(View.GONE); // add elements to body view messageView.addView(icon); messageView.addView(title); messageView.addView(message); messageView.addView(checkBox); // button area LayoutParams btnsParams = new LayoutParams((int) dialog_width, (int) (52.0f * density)); LinearLayout buttons = new LinearLayout(this.getContext()); buttons.setMinimumHeight((int) (52.0f * density)); buttons.setLayoutParams(btnsParams); buttons.setGravity(Gravity.RIGHT | Gravity.CENTER); buttons.setId(android.R.id.extractArea); buttons.setPadding(0, 0, (int) (8.0f * density), 0); contentView.addView(messageView); contentView.addView(buttons); this.setContentView(contentView); }
@SuppressWarnings("deprecation") private void init(Context context, int initialColor) { setPadding(UI.dialogMargin, UI.dialogMargin, UI.dialogMargin, UI.dialogMargin); final int eachW = (UI._18sp * 7) >> 1; final boolean smallScreen = (UI.isLowDpiScreen && !UI.isLargeScreen); initialColor = 0xff000000 | (initialColor & 0x00ffffff); hsv = new HSV(); hsv.fromRGB(initialColor); hsvTmp = new HSV(); bmpRect = new Rect(0, 0, 1, 1); this.initialColor = initialColor; currentColor = initialColor; sliderColor = (UI.isAndroidThemeLight() ? 0xff000000 : 0xffffffff); final LinearLayout l = new LinearLayout(context); l.setId(1); l.setWeightSum(2); LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); addView(l, p); final TextView lbl = new TextView(context); lbl.setBackgroundDrawable(new ColorDrawable(initialColor)); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize); lp.weight = 1; lp.rightMargin = UI.controlSmallMargin; l.addView(lbl, lp); bgCurrent = new ColorDrawable(initialColor); lblCurrent = new TextView(context); lblCurrent.setBackgroundDrawable(bgCurrent); lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, smallScreen ? (UI.defaultControlSize) >> 1 : UI.defaultControlSize); lp.weight = 1; lp.leftMargin = UI.controlSmallMargin; l.addView(lblCurrent, lp); final int textSize = (smallScreen ? UI._14sp : UI._18sp); TextView lblTit = new TextView(context); lblTit.setId(2); lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); lblTit.setSingleLine(); lblTit.setGravity(Gravity.CENTER); lblTit.setText("H"); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); p.addRule(RelativeLayout.BELOW, 1); addView(lblTit, p); lblTit = new TextView(context); lblTit.setId(3); lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); lblTit.setSingleLine(); lblTit.setGravity(Gravity.CENTER); lblTit.setText("S"); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); p.addRule(RelativeLayout.BELOW, 1); addView(lblTit, p); lblTit = new TextView(context); lblTit.setId(4); lblTit.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); lblTit.setSingleLine(); lblTit.setGravity(Gravity.CENTER); lblTit.setText("V"); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); p.addRule(RelativeLayout.BELOW, 1); addView(lblTit, p); barH = new BgSeekBar(context); barH.setId(5); barH.setMax(360); barH.setValue((int) (hsv.h * 360.0)); barH.setSliderMode(true); barH.setVertical(true); p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.leftMargin = ((eachW - UI.defaultControlSize) >> 1); p.addRule(RelativeLayout.ALIGN_LEFT, 2); p.addRule(RelativeLayout.BELOW, 2); p.addRule(RelativeLayout.ABOVE, 6); addView(barH, p); barS = new BgSeekBar(context); barS.setMax(100); barS.setValue((int) (hsv.s * 100.0)); barS.setSliderMode(true); barS.setVertical(true); p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.leftMargin = ((eachW - UI.defaultControlSize) >> 1); p.addRule(RelativeLayout.ALIGN_LEFT, 3); p.addRule(RelativeLayout.BELOW, 3); p.addRule(RelativeLayout.ABOVE, 6); addView(barS, p); barV = new BgSeekBar(context); barV.setMax(100); barV.setValue((int) (hsv.v * 100.0)); barV.setSliderMode(true); barV.setVertical(true); p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.leftMargin = ((eachW - UI.defaultControlSize) >> 1); p.addRule(RelativeLayout.ALIGN_LEFT, 4); p.addRule(RelativeLayout.BELOW, 4); p.addRule(RelativeLayout.ABOVE, 6); addView(barV, p); txtH = new EditText(context); txtH.setId(6); txtH.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); txtH.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); txtH.setSingleLine(); txtH.setGravity(Gravity.CENTER); txtH.setText(Integer.toString((int) (hsv.h * 360.0))); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ABOVE, 7); addView(txtH, p); txtS = new EditText(context); txtS.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); txtS.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); txtS.setSingleLine(); txtS.setGravity(Gravity.CENTER); txtS.setText(Integer.toString((int) (hsv.s * 100.0))); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); p.addRule(RelativeLayout.ABOVE, 7); addView(txtS, p); txtV = new EditText(context); txtV.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); txtV.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); txtV.setSingleLine(); txtV.setGravity(Gravity.CENTER); txtV.setText(Integer.toString((int) (hsv.v * 100.0))); p = new LayoutParams(eachW, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ABOVE, 7); addView(txtV, p); txt = new EditText(context); txt.setId(7); txt.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); txt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); txt.setSingleLine(); txt.setGravity(Gravity.CENTER); txt.setText(ColorUtils.toHexColor(initialColor)); p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); p.topMargin = UI.dialogMargin; p.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); p.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); addView(txt, p); lbl.setOnClickListener(this); barH.setOnBgSeekBarChangeListener(this); barH.setOnBgSeekBarDrawListener(this); barS.setOnBgSeekBarChangeListener(this); barS.setOnBgSeekBarDrawListener(this); barV.setOnBgSeekBarChangeListener(this); barV.setOnBgSeekBarDrawListener(this); txtH.addTextChangedListener(this); txtS.addTextChangedListener(this); txtV.addTextChangedListener(this); txt.addTextChangedListener(this); }
@SuppressWarnings("deprecation") public CreditCardEntry( Context context, boolean includeExp, boolean includeSecurity, boolean includeZip, AttributeSet attrs, int style) { super(context); this.context = context; TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CreditCardForm, 0, 0); textColor = typedArray.getColor(R.styleable.CreditCardForm_text_color, Color.BLACK); typedArray.recycle(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width; if (android.os.Build.VERSION.SDK_INT < 13) { width = display.getWidth(); // deprecated } else { Point size = new Point(); display.getSize(size); width = size.x; } LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; setLayoutParams(params); this.setHorizontalScrollBarEnabled(false); this.setOnTouchListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { container = new LinearLayout(context); } else { container = new LinearLayout(context); } container.setId(R.id.cc_entry_internal); container.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); container.setOrientation(LinearLayout.HORIZONTAL); creditCardText = new CreditCardText(context, attrs); creditCardText.setId(R.id.cc_card); creditCardText.setDelegate(this); creditCardText.setWidth(width); container.addView(creditCardText); includedFields.add(creditCardText); CreditEntryFieldBase currentField = creditCardText; textFourDigits = new TextView(context); textFourDigits.setTextSize(20); textFourDigits.setTextColor(textColor); container.addView(textFourDigits); expDateText = new ExpDateText(context, attrs); expDateText.setId(R.id.cc_exp); if (includeExp) { expDateText.setDelegate(this); container.addView(expDateText); nextFocusField.put(currentField, expDateText); prevFocusField.put(expDateText, currentField); currentField = expDateText; includedFields.add(currentField); } securityCodeText = new SecurityCodeText(context, attrs); securityCodeText.setId(R.id.cc_ccv); if (includeSecurity) { securityCodeText.setDelegate(this); if (!includeZip) { securityCodeText.setImeActionLabel("Done", EditorInfo.IME_ACTION_DONE); } securityCodeText.setOnEditorActionListener( new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId) { onSecurityCodeValid(); return true; } return false; } }); container.addView(securityCodeText); nextFocusField.put(currentField, securityCodeText); prevFocusField.put(securityCodeText, currentField); currentField = securityCodeText; includedFields.add(currentField); } zipCodeText = new ZipCodeText(context, attrs); zipCodeText.setId(R.id.cc_zip); if (includeZip) { zipCodeText.setDelegate(this); container.addView(zipCodeText); zipCodeText.setImeActionLabel("DONE", EditorInfo.IME_ACTION_DONE); zipCodeText.setOnEditorActionListener( new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId) { onZipCodeValid(); return true; } return false; } }); nextFocusField.put(currentField, zipCodeText); prevFocusField.put(zipCodeText, currentField); currentField = zipCodeText; includedFields.add(currentField); } nextFocusField.put(currentField, null); this.addView(container); // when the user taps the last 4 digits of the card, they probably want to edit it textFourDigits.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { focusOnField(creditCardText); } }); }
@Override public void handleMessage(Message msg) { if (!possibleLogTypes.contains(typeSelected)) { typeSelected = possibleLogTypes.get(0); setType(typeSelected); showToast(res.getString(R.string.info_log_type_changed)); } if (cgBase.isEmpty(viewstates) && attempts < 2) { final LoadDataThread thread; thread = new LoadDataThread(); thread.start(); return; } else if (cgBase.isEmpty(viewstates) && attempts >= 2) { showToast(res.getString(R.string.err_log_load_data)); showProgress(false); return; } gettingViewstate = false; // we're done, user can post log enablePostButton(true); // add trackables if (CollectionUtils.isNotEmpty(trackables)) { if (inflater == null) { inflater = getLayoutInflater(); } final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory); inventoryView.removeAllViews(); for (cgTrackableLog tb : trackables) { LinearLayout inventoryItem = (LinearLayout) inflater.inflate(R.layout.visit_trackable, null); ((TextView) inventoryItem.findViewById(R.id.trackcode)).setText(tb.trackCode); ((TextView) inventoryItem.findViewById(R.id.name)).setText(tb.name); ((TextView) inventoryItem.findViewById(R.id.action)) .setText( res.getString( Settings.isTrackableAutoVisit() ? LogTypeTrackable.VISITED.resourceId : LogTypeTrackable.DO_NOTHING.resourceId) + " ▼"); inventoryItem.setId(tb.id); final String tbCode = tb.trackCode; inventoryItem.setClickable(true); registerForContextMenu(inventoryItem); inventoryItem .findViewById(R.id.info) .setOnClickListener( new View.OnClickListener() { public void onClick(View view) { final Intent trackablesIntent = new Intent(VisitCacheActivity.this, cgeotrackable.class); trackablesIntent.putExtra(EXTRAS_GEOCODE, tbCode); startActivity(trackablesIntent); } }); inventoryItem .findViewById(R.id.action) .setOnClickListener( new View.OnClickListener() { public void onClick(View view) { openContextMenu(view); } }); inventoryView.addView(inventoryItem); if (Settings.isTrackableAutoVisit()) { tb.action = LogTypeTrackable.VISITED; tbChanged = true; } } if (inventoryView.getChildCount() > 0) { ((LinearLayout) findViewById(R.id.inventory_box)).setVisibility(View.VISIBLE); } if (inventoryView.getChildCount() > 1) { final LinearLayout inventoryChangeAllView = (LinearLayout) findViewById(R.id.inventory_changeall); final Button changeButton = (Button) inventoryChangeAllView.findViewById(R.id.changebutton); registerForContextMenu(changeButton); changeButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { openContextMenu(view); } }); inventoryChangeAllView.setVisibility(View.VISIBLE); } } showProgress(false); }
@Override public void handleMessage(Message msg) { if (types.contains(typeSelected) == false) { typeSelected = types.get(0); setType(typeSelected); showToast(res.getString(R.string.info_log_type_changed)); } if ((viewstate == null || viewstate.length() == 0) && attempts < 2) { showToast(res.getString(R.string.err_log_load_data_again)); loadData thread; thread = new loadData(cacheid); thread.start(); return; } else if ((viewstate == null || viewstate.length() == 0) && attempts >= 2) { showToast(res.getString(R.string.err_log_load_data)); showProgress(false); return; } gettingViewstate = false; // we're done, user can post log if (post == null) { post = (Button) findViewById(R.id.post); } post.setEnabled(true); post.setOnClickListener(new postListener()); // add trackables if (trackables != null && trackables.isEmpty() == false) { if (inflater == null) { inflater = getLayoutInflater(); } final LinearLayout inventoryView = (LinearLayout) findViewById(R.id.inventory); inventoryView.removeAllViews(); for (cgTrackableLog tb : trackables) { LinearLayout inventoryItem = (LinearLayout) inflater.inflate(R.layout.visit_trackable, null); ((TextView) inventoryItem.findViewById(R.id.trackcode)).setText(tb.trackCode); ((TextView) inventoryItem.findViewById(R.id.name)).setText(tb.name); ((TextView) inventoryItem.findViewById(R.id.action)) .setText(cgBase.logTypesTrackable.get(settings.trackableAutovisit ? 1 : 0)); inventoryItem.setId(tb.id); final String tbCode = tb.trackCode; inventoryItem.setClickable(true); registerForContextMenu(inventoryItem); inventoryItem .findViewById(R.id.info) .setOnClickListener( new View.OnClickListener() { public void onClick(View view) { final Intent trackablesIntent = new Intent(cgeovisit.this, cgeotrackable.class); trackablesIntent.putExtra("geocode", tbCode); startActivity(trackablesIntent); } }); inventoryItem .findViewById(R.id.action) .setOnClickListener( new View.OnClickListener() { public void onClick(View view) { openContextMenu(view); } }); inventoryView.addView(inventoryItem); if (settings.trackableAutovisit) { tb.action = 1; tbChanged = true; } } if (inventoryView.getChildCount() > 0) { ((LinearLayout) findViewById(R.id.inventory_box)).setVisibility(View.VISIBLE); } if (inventoryView.getChildCount() > 1) { final LinearLayout inventoryChangeAllView = (LinearLayout) findViewById(R.id.inventory_changeall); Button changeButton = (Button) inventoryChangeAllView.findViewById(R.id.changebutton); registerForContextMenu(changeButton); changeButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { openContextMenu(view); } }); ((LinearLayout) findViewById(R.id.inventory_changeall)).setVisibility(View.VISIBLE); } } showProgress(false); }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final EventsDetails objEventsDetails = vctUpcomingEvents.get(position); convertView = (LinearLayout) getLayoutInflater().inflate(R.layout.list_events_cell, null); TextView tvUpName = (TextView) convertView.findViewById(R.id.tvUpName); TextView tvstartDate = (TextView) convertView.findViewById(R.id.tvStartdate); TextView tvPrice = (TextView) convertView.findViewById(R.id.tvPrice); ImageView ivEventIcon = (ImageView) convertView.findViewById(R.id.ivEventIcon); LinearLayout llFavourite = (LinearLayout) convertView.findViewById(R.id.llStar); LinearLayout llShare = (LinearLayout) convertView.findViewById(R.id.llShare); ProgressBar eventicon_progress_bar = (ProgressBar) convertView.findViewById(R.id.eventicon_progress_bar); ProgressBar event_progress_bar = (ProgressBar) convertView.findViewById(R.id.event_progress_bar); event_progress_bar.setVisibility(View.GONE); final int eventId = objEventsDetails.eventid; llShare.setId(eventId); try { convertView.setId(eventId); tvUpName.setText(objEventsDetails.eventname); tvstartDate.setText( objEventsDetails.event_start_date + " " + objEventsDetails.event_start_time); tvPrice.setText(objEventsDetails.price); if (!objEventsDetails.images.get(0).imagesrc.equals(AppConstants.NOIMAGE)) { if (!objDrawableManager.fetchDrawableOnThread( AppConstants.IMAGE_HOST_URL + objEventsDetails.images.get(0).imagesrc, ivEventIcon, 65, 65, objEventsDetails.imageId, objEventsDetails.isImageUpdated)) { eventicon_progress_bar.setVisibility(View.GONE); ivEventIcon.setImageResource(R.drawable.no_image_event); } } else { eventicon_progress_bar.setVisibility(View.GONE); ivEventIcon.setImageResource(R.drawable.no_image_event); } } catch (Exception EE) { } llFavourite.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { showFavouritePopup(eventId); } }); llShare.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { showSharePopup(v.getId()); } }); convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent inttentEventDetails = new Intent(MoreEventsByBusiness.this, EventDetails.class); inttentEventDetails.putExtra(EVENTID, v.getId()); overridePendingTransition(R.anim.slide_left, R.anim.slide_right); TabGroupActivity pActivity = (TabGroupActivity) MoreEventsByBusiness.this.getParent(); pActivity.startChildActivity(SEARCHEDEVENT, inttentEventDetails); } }); return convertView; }