@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); paoPaoQuan.setSelection(paoPaoState); // requestCode标示请求的标示 resultCode表示有数据 Log.d("js", requestCode + "//" + resultCode + "**" + data); if (requestCode==4||data != null) { int childCount = imageGrid.getChildCount(); if (childCount > 9) { Toast.makeText(this, "最多选择9张图片", 1).show(); } else { imageId++; String fPath = null; if (requestCode == 4) { fPath = mCurrentPhotoPath; }else{ Uri uri = data.getData(); // 得到Uri if((uri!=null&&!uri.equals(""))){ fPath = StaticMethod.getImageAbsolutePath(this, uri); // 转化为路径 } } Bitmap b = BitmapFactory.decodeFile(fPath); b = StaticMethod.getThumImg(b, 100); ImageView image = new ImageView(this); image.setLayoutParams(new LayoutParams(130, 130)); image.setScaleType(ScaleType.FIT_XY); image.setId(imageId); image.setTag(fPath); image.setImageBitmap(b); image.setOnClickListener(this); imageGrid.addView(image, childCount - 1); } } }
public void addNumChildView(String aName, String aNumber) { positon++; tv_men = new TextView(NewSMSActivity.this); tv_men.setText(aName.trim()); LayoutParams tvLay = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tvLay.setMargins(5, 5, 5, 5); tv_men.setPadding(3, 3, 3, 3); tv_men.setLayoutParams(tvLay); tv_men.setBackgroundColor(Color.BLUE); tv_men.setTextColor(Color.GRAY); tv_men.setTextSize(12); tv_men.setTextAppearance(NewSMSActivity.this, R.style.textview_number); tv_men.setId(positon); tv_men.setTag(Boolean.valueOf(false)); tv_men.setOnClickListener(NewSMSActivity.this); menMap.put(String.valueOf(tv_men.getId()), tv_men); flowLayout.addView(tv_men, flowLayout.getChildCount() - 1); ContactMen contactMen = new ContactMen(); contactMen.setName(aName.trim()); contactMen.setNumber(aNumber.trim()); smsSendMen.put(String.valueOf(tv_men.getId()), contactMen); }
@Override public void showAtLocation(View parent, int gravity, int x, int y) { if(App.currentUser != null) { userId = App.currentUser.getId(); } collect = collectDAO.getCollect(userId, mJoke.getId()); if(collect != null) { //收藏过 getContentView().findViewById(R.id.share_collect).setSelected(true); } else { getContentView().findViewById(R.id.share_collect).setSelected(false); } Activity activity = ((Activity)context).getParent(); if(activity == null) { activity = ((Activity)context); } WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.alpha = 0.4f; activity.getWindow().setAttributes(lp); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); super.showAtLocation(parent, gravity, x, y); }
public static void a(Context paramContext, SearchView paramSearchView, int paramInt1, int paramInt2, int paramInt3, int paramInt4) { ImageView localImageView = (ImageView)paramSearchView.findViewById(eyg.bT); int i1 = ((git)mbb.a(paramContext, git.class)).c(); if (((djp)mbb.a(paramContext, djp.class)).a(i1)) { localImageView.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); paramSearchView.findViewById(eyg.bU).setBackgroundResource(0); paramSearchView.setLayoutParams(new ActionBar.LayoutParams(-1, -2)); } for (;;) { ((ImageView)paramSearchView.findViewById(eyg.bS)).setImageResource(paramInt2); SearchView.SearchAutoComplete localSearchAutoComplete = (SearchView.SearchAutoComplete)paramSearchView.findViewById(eyg.bV); Resources localResources = paramContext.getResources(); localSearchAutoComplete.setTextColor(localResources.getColor(paramInt3)); localSearchAutoComplete.setHintTextColor(localResources.getColor(paramInt4)); return; localImageView.setImageResource(paramInt1); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if(viewHolder == null) { convertView = mInflater.inflate(R.layout.item_recorder, parent, false); viewHolder = new ViewHolder(); viewHolder.seconds = (TextView) convertView.findViewById(R.id.id_time); viewHolder.length = convertView.findViewById(R.id.id_recorder_length); convertView.setTag(viewHolder); }else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.seconds.setText(Math.round(getItem(position).getTime()) + "\""); ViewGroup.LayoutParams lp = viewHolder.length.getLayoutParams(); lp.width = (int) (minItemWidth + maxItemWidth /60f * getItem(position).getTime()); return convertView; }
public void show(Context context) { mActionBar = ((Activity) context).getActionBar(); mActionBar.setDisplayShowCustomEnabled(true); //是否可以使用自定义布局 mActionBar.setDisplayShowHomeEnabled(false); //显示程序图标 mActionBar.setDisplayShowTitleEnabled(false); //是否显示系统的title mActionBar.setDisplayUseLogoEnabled(false); //setDisplayShowTitleEnabled和setDisplayShowHomeEnabled共同起作用 // mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM // | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); View view = LayoutInflater.from(context).inflate(R.layout.local_actionbar, null); mLeftTitle = (TextView) view.findViewById(R.id.left_title); mRightTitle = (TextView) view.findViewById(R.id.right_title); mMideleTitle = (TextView) view.findViewById(R.id.middle_title); mActionBar.setCustomView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mActionBar.show(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout frame = new FrameLayout(this); frame.setId(CONTENT_VIEW_ID); setContentView(frame, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); if (savedInstanceState == null) { // Fragment newFragment = new DebugExampleTwoFragment(); Fragment detailFragment = new CardsDetailFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(CONTENT_VIEW_ID, detailFragment).commit(); } ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout frame = new FrameLayout(this); frame.setId(CONTENT_VIEW_ID); setContentView(frame, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); if (savedInstanceState == null) { // Fragment newFragment = new DebugExampleTwoFragment(); Fragment charFragment = new CardsPartyFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(CONTENT_VIEW_ID, charFragment).commit(); } ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); }
@Override public void onResume() { super.onResume(); if (tile != null) { ViewGroup vg = (ViewGroup)this.getActivity().findViewById(R.id.universal_frame_tile); //Check whether the view group is available. If so, this activity is a frame tile host if (vg != null) { if (tile.getParent() != null) { ((ViewGroup)tile.getParent()).removeView(tile); } vg.addView(tile, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); //this doesn't really make it over well mInternalDetailView = null; } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_step_count); Button startBtn = (Button) this.findViewById(R.id.startRecord); Button endBtn = (Button) this.findViewById(R.id.endRecord); startBtn.setOnClickListener(listener); endBtn.setOnClickListener(listener); mStepValue = 0; isServiceRunning = false; LinearLayout linearView=(LinearLayout)findViewById(R.id.chart); linearView.setVisibility(View.GONE); sensorChart = new SensorChart(); mChartStatus = MENU_MAP; //chartView = sensorChart.getDemoChartGraphicalView(this); //linearView.addView(chartView, // new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); LinearLayout mapLinearView=(LinearLayout)findViewById(R.id.mapchart); mapLinearView.setVisibility(View.VISIBLE); glView = new MapChart(this); mapLinearView.addView(glView, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. // getMenuInflater().inflate(null, menu); ActionBar actionBar = getActionBar(); actionBarHeight = actionBar.getHeight(); ActionBar.LayoutParams params = new ActionBar.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER); View view = LayoutInflater.from(this) .inflate(R.layout.main_title, null); actionBar.setCustomView(view, params); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayShowCustomEnabled(true); ivTitleBtnRight = (ImageButton) this.findViewById(R.id.ivTitleBtnRight); ivTitleBtnLeft = (ImageButton) this.findViewById(R.id.ivTitleBtnLeft); titleText = (TextView) this.findViewById(R.id.ivTitleName); ivTitleBtnLeft.setOnClickListener(this); ivTitleBtnRight.setOnClickListener(this); return true; }
@SuppressLint("NewApi") protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); switch (requestCode) { case SELECT_PHOTO: if (resultCode == RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); url = cursor.getString(columnIndex); cursor.close(); ImageView imView = new ImageView(this); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); imView.setLayoutParams(lp); Bitmap bm = BitmapFactory.decodeFile(url); imView.setImageBitmap(bm); LinearLayout ll = (LinearLayout) findViewById(R.id.image_container); ll.addView(imView); } } }
public static void showPopup(final Context c, final Pharmacy a) { Dialog d = new Dialog(c); d.setContentView(R.layout.popup_layout); d.setTitle(a.getName()); ((TextView) d.findViewById(R.id.apo_name)).setText(c.getString(R.string.name) + ": " + a.getName()); ((TextView) d.findViewById(R.id.apo_address)).setText(c.getString(R.string.address) + ": " + a.getAddress()); ((TextView) d.findViewById(R.id.apo_zipcode)).setText(c.getString(R.string.zipcode) + ": " + a.getZipcode()); ((TextView) d.findViewById(R.id.apo_town)).setText(c.getString(R.string.town) + ": " + a.getTown()); if (!a.getTelnr().isEmpty()) { LinearLayout ll = (LinearLayout) d.findViewById(R.id.layout); TextView tel = new TextView(c); tel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1)); tel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); tel.setText(c.getString(R.string.tel) + ": " + a.getTelnr()); Linkify.addLinks(tel, Pattern.compile("\\+?(\\d){8,11}"), "tel:"); ll.addView(tel); } d.show(); }
private void setActionBarOptions() { View v = getLayoutInflater().inflate(R.layout.test_list_options, null); SharedPreferences sp = getSharedPreferences(PREFS, MODE_PRIVATE); CheckBox cb = (CheckBox) v.findViewById(R.id.single_mode); cb.setChecked(sp.getBoolean(KEY_SINGLE_MODE, false)); cb.setOnCheckedChangeListener(this); LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL; getActionBar().setCustomView(v, lp); int flags = ActionBar.DISPLAY_SHOW_CUSTOM; int options = getActionBar().getDisplayOptions() ^ flags; getActionBar().setDisplayOptions(options, flags); }
@Override public void onStart() { super.onStart(); final Dialog dialog = getDialog(); if (dialog != null) { final Window windowDialog = dialog.getWindow(); if (windowDialog != null) { if (Utils.isLandscape(getActivity())) { final int width = ViewGroup.LayoutParams.MATCH_PARENT; final int height = ViewGroup.LayoutParams.MATCH_PARENT; windowDialog.setLayout(width, height); } } } }
private void popUpCalendarView() { if (calendarPopup == null) { LayoutInflater inflater = LayoutInflater.from(this); calendarPopupView = inflater.inflate(R.layout.calendar_layout, null); calendarPopup = new PopupWindow(calendarPopupView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, true); calendarPopup.setFocusable(true); calendarPopup.setBackgroundDrawable(new BitmapDrawable()); calendar_month_text = (TextView) calendarPopupView.findViewById(R.id.calendar_month_text); calendar_year_text = (TextView) calendarPopupView.findViewById(R.id.calendar_year_text); calendar_close_btn = (LinearLayout) calendarPopupView.findViewById(R.id.calendar_close_btn); calendar_all_time_btn = (LinearLayout) calendarPopupView.findViewById(R.id.calendar_all_time_btn); calendar_arrow_left = (ImageView) calendarPopupView.findViewById(R.id.calendar_arrow_left); calendar_arrow_right = (ImageView) calendarPopupView.findViewById(R.id.calendar_arrow_right); calendar_view = (CalendarView) calendarPopupView.findViewById(R.id.calendar_view); calendar_view.setOnItemClickListener(this); calendar_arrow_left.setOnClickListener(this); calendar_arrow_right.setOnClickListener(this); calendar_close_btn.setOnClickListener(this); calendar_all_time_btn.setOnClickListener(this); if(android.os.Build.VERSION.SDK_INT >= 19 ){ if(CommUtil.checkDeviceHasNavigationBar(this)){ y = CommUtil.getNavigationBarHeight(this); } } } if (date_click == null) { Calendar date = Calendar.getInstance(); calendar_year_text.setText("" + date.get(Calendar.YEAR)); calendar_month_text.setText("" + month_name[date.get(Calendar.MONTH)]); } calendarPopup.showAtLocation(this.findViewById(R.id.videolist_root), Gravity.BOTTOM, 0, y); }
private void showProgress(){ ProgressBar progressBar=new ProgressBar(MainActivity.this,null, android.R.attr.progressBarStyleLargeInverse); progressBar.setMax(1000); RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT); progressBar.setLayoutParams(params); layout.addView(progressBar); }
/** * 初始化窗口 */ private void initWindow() { this.setClippingEnabled(false); this.setWidth(LayoutParams.MATCH_PARENT); //设置弹出窗体的高 this.setHeight(LayoutParams.WRAP_CONTENT); //设置弹出窗体可点击 this.setFocusable(true); //设置弹出窗体动画效果 this.setAnimationStyle(R.style.inoutformbottom); //实例化一个ColorDrawable颜色为半透明 (在此设置背景后此窗口不会出现黑色边框) ColorDrawable dw = new ColorDrawable(0xFFFFFFFF); //设置SelectPicPopupWindow弹出窗体的背景 this.setBackgroundDrawable(dw); //popupwindow消失的时候让窗口背景恢复 this.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { Activity activity = ((Activity) context).getParent(); if (activity == null) { activity = ((Activity) context); } WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); lp.alpha = 1f; activity.getWindow().setAttributes(lp); } }); }
/** * ��ʾ */ public void show(View parent){ DisplayMetrics dm = m_MapControl.getContext().getResources().getDisplayMetrics(); // showAt(0, 0, 400 * (int)dm.density, 90 * (int)dm.density); setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); Rect outRect = new Rect(); m_MainActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect); showAtLocation(m_MainView, Gravity.LEFT | Gravity.TOP, 8, (int)((120 * dm.density)/2)+ 10 + outRect.top); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.photo_select_dialog); getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//(全屏)需要添加的语句 initView(); initListener(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setTitle(" Played bitrates for different ISPs"); LinearLayout parent=new LinearLayout(this); parent.setOrientation(LinearLayout.VERTICAL); getISP(this); Set<String> keyset = map.keySet(); String[] ISP = keyset.toArray(new String[keyset.size()]); for (int i=0; i<ISP.length; i++){ if(ISP[i].equals("")){ continue; } LinearLayout layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 600)); layout.setBottom(30); layout.setOrientation(LinearLayout.VERTICAL); GraphicalView piechart = new PieChart(ISP[i], readInfo(this, ISP[i])).execute(this); layout.addView(piechart, new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); parent.addView(layout); } ScrollView scroll = new ScrollView(this); scroll.setBackgroundColor(Color.BLACK); scroll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); scroll.addView(parent); setContentView(scroll); }
private void setCustomActionBarView() { ActionBar.LayoutParams lp = new ActionBar.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER); View actionBarView = getLayoutInflater().inflate( R.layout.activity_login, null); getActionBar().setCustomView(actionBarView, lp); getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setDisplayShowCustomEnabled(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.CustomTutorialTheme); setContentView(R.layout.tutorials_card); this.entries = (ArrayList<TutorialEntry>) getIntent().getSerializableExtra("entries"); switcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); next = (Button) findViewById(R.id.nextButton); descriptionText = (TextView) findViewById(R.id.descriptionText); previous = (Button) findViewById(R.id.previousButton); previous.setVisibility(View.INVISIBLE); next.setOnClickListener(this); previous.setOnClickListener(this); switcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView myView = new ImageView(getApplicationContext()); myView.setScaleType(ImageView.ScaleType.FIT_CENTER); myView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams. FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); myView.setImageResource(entries.get(index).image); return myView; } }); // Gesture detection gestureDetector = new GestureDetector(this, new SwipeGestureDetector()); gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); } }; descriptionText.setText(entries.get(index).description); // Do this for each view added to the grid switcher.setOnTouchListener(gestureListener); }
private void attachBreadcrumbBar(Activity activity, ActionBar actionBar) { //make sure we're in the right mode actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); //We need to get the amount that each item should "bleed" over to the left, and move the whole widget that //many pixels. This replicates the "overlap" space that each piece of the bar has on the next piece for //the left-most element. int buffer = Math.round(activity.getResources().getDimension(R.dimen.title_round_bleed)); LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); p.leftMargin = buffer; activity.setTitle(""); actionBar.setDisplayShowHomeEnabled(false); }
private View findAndLoadCaseTile(final Activity activity) { final View holder = LayoutInflater.from(activity).inflate(R.layout.com_tile_holder, null); final Pair<View, TreeReference> tileData = this.loadTile(activity); if (tileData == null || tileData.first == null) { return null; } View tile = tileData.first; final String inlineDetail = (String)tile.getTag(); ((ViewGroup)holder.findViewById(R.id.com_tile_holder_frame)).addView(tile, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ImageButton infoButton = ((ImageButton)holder.findViewById(R.id.com_tile_holder_btn_open)); if (inlineDetail == null) { infoButton.setVisibility(View.GONE); } holder.setTag(INLINE_TILE_COLLAPSED); infoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean isCollapsed = INLINE_TILE_COLLAPSED.equals(holder.getTag()); if (isCollapsed) { expandInlineTile(activity, holder, tileData, inlineDetail); } else { collapseTileIfExpanded(activity); } } }); return holder; }
public void bind( Atom atom ) { mAtom = atom; TextView typeView = (TextView) mView.findViewById( R.id.box_type ); typeView.setText( mAtom.getType() ); RelativeLayout root = (RelativeLayout) mView.findViewById( R.id.atom_root ); root.setClickable( atom.getChildCount() == 0 ? false : true ); View paddingView = mView.findViewById( R.id.padding_view ); paddingView.setLayoutParams( new RelativeLayout.LayoutParams( dpToPx( 16 * mAtom.getDepth() ), LayoutParams.MATCH_PARENT ) ); TextView descriptionView = (TextView) mView.findViewById( R.id.box_description ); String name = mAtom.getName(); descriptionView.setText( name ); final ImageView boxIcon = (ImageView) mView.findViewById( R.id.box_icon ); boxIcon.setVisibility( atom.getChildCount() == 0 ? View.INVISIBLE : View.VISIBLE ); if ( atom.getChildCount() > 0 ) { boxIcon.post( new Runnable() { @Override public void run() { int from = mAtom.isExpanded() ? -90 : 0; int to = mAtom.isExpanded() ? 0 : -90; RotateAnimation animation = new RotateAnimation( from, to, boxIcon.getWidth() / 2, boxIcon.getHeight() / 2 ); animation.setDuration( 0 ); animation.setFillAfter( true ); boxIcon.startAnimation( animation ); } } ); } }
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { _view = new RelativeLayout(getActivity()); _view.setBackgroundColor(Color.GRAY); ImageView imageView = new ImageView(getActivity()); imageView.setImageResource(R.drawable.ic_launcher); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; imageView.setLayoutParams(params); _view.addView(imageView); return _view; }
public LinearLayout renderLayout(TableLayout table, TableLayout cbs) { //prepare LinearLayout rtn = new LinearLayout(this); rtn.setOrientation(LinearLayout.VERTICAL); ScrollView v = new ScrollView(this); v.addView(table); TextView cbLabel = new TextView(this); cbLabel.setText("\n\nSelect Access Points to keep: "); ScrollView v2 = new ScrollView(this); v2.addView(cbs); //add LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, 0, 0.5f); v.setLayoutParams(param1); rtn.addView(v); LinearLayout.LayoutParams param2 = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, 0, 0.1f); cbLabel.setLayoutParams(param2); rtn.addView(cbLabel); LinearLayout.LayoutParams param3 = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, 0, 0.3f); v2.setLayoutParams(param3); rtn.addView(v2); LinearLayout.LayoutParams param4 = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, 0, 0.1f); buildButton.setLayoutParams(param4); rtn.addView(buildButton); return rtn; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_main); showLoadingDialog(); manufature = 1; language = 0; ActionBar actionBar = getActionBar(); actionBar.setDisplayShowCustomEnabled(true); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); navigation = LayoutInflater.from(this).inflate(R.layout.option_menu, null); actionBar.setCustomView(navigation, lp); optv1 = (TextView) navigation.findViewById(R.id.op_tv1); optv2 = (TextView) navigation.findViewById(R.id.op_tv2); op_tv3 = (TextView) navigation.findViewById(R.id.op_tv3); langImg = (ImageView) navigation.findViewById(R.id.language); langImg.setOnClickListener(this); optv1.setOnClickListener(this); optv2.setOnClickListener(this); op_tv3.setOnClickListener(this); mListView = (ListView) findViewById(R.id.listview); atm = AsyncTaskManager.getInstance(this); getData.start(); mSongs = new ArrayList<ArrayList<Song>>(); }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); LinearLayout layout = (LinearLayout)findViewById(R.id.resource_buttons); Button button = new Button(this); button.setText(R.string.applyDefault); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SettingsDB helper = new SettingsDB(v.getContext()); SQLiteDatabase db = helper.getWritableDatabase(); db.delete(resource.tableName(), SettingsDB.COL_PKG_NAME + " =?", new String[] {pkgName}); db.close(); Context context = view.getContext(); String[] processes = null; try { processes = Utilities.getProcesses(context, pkgName); Utilities.killApp(context, pkgName, processes); } catch (NameNotFoundException e) { Log.d(Utilities.ERROR, "problems killing app: "+pkgName+" with processes: "+Arrays.toString(processes)); } finish(); } }); layout.addView(button, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); }
private int canSetTranslucentFlag() { Resources resources = getResources(); int id = resources.getIdentifier("config_enableTranslucentDecor", "bool", "android"); if (id != 0) { boolean enabled = resources.getBoolean(id); if (enabled) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, //WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); if (id > 0) { if (!resources.getBoolean(id)) return 0; } else { return 0; } id = resources.getIdentifier("navigation_bar_height", "dimen", "android"); if (id > 0) { return resources.getDimensionPixelSize(id); } } } return 0; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ArrayList<Restaurant> restaurants = new RestaurantXMLFetcher().getRestaurants(this); // Create a progress bar to display while the list loads ProgressBar progressBar = new ProgressBar(this); progressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); progressBar.setIndeterminate(true); getListView().setEmptyView(progressBar); // Must add the progress bar to the root of the layout ViewGroup root = (ViewGroup) findViewById(android.R.id.content); root.addView(progressBar); RestaurantApplication app = (RestaurantApplication) getApplication(); Restaurant stuff = app.getCurrentRestaurant(); ListView listview = getListView(); ArrayList<Restaurant> list = app.getRestaurants(); if (list.isEmpty()) { Iterator<Restaurant> it = restaurants.iterator(); while (it.hasNext()) { if(!(it.next().match(stuff))) it.remove(); } list = restaurants; app.setRestaurants(restaurants); } listview.setAdapter(new RestaurantAdapter(this, android.R.layout.simple_list_item_1, list)); }
/** * 初始化快捷菜单 */ private void initConvenientView() { /* PathView mPathView = (PathView) this .findViewById(R.id.mPathView_uitilsmodem); ImageButton startMenu = new ImageButton(MainTimeLineActivity.this); startMenu.setBackgroundResource(R.drawable.start_menu_btn); mPathView.setStartMenu(startMenu); mPathView.setItems(new View[0]); mPathView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(MainTimeLineActivity.this, WriteWeiboActivity.class); intent.putExtra("token", getToken()); intent.putExtra("account", getAccount()); startActivity(intent); } });*/ floatView=new FloatView(getApplicationContext()); floatView.setImageResource(R.drawable.white_weibo_menuitem_button); windowManager=(WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); windowManagerParams=((GlobalContext)getApplication()).getWindowParams(); windowManagerParams.type=android.view.WindowManager.LayoutParams.TYPE_PHONE; windowManagerParams.format = PixelFormat.RGBA_8888; windowManagerParams.flags = android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; windowManagerParams.gravity = Gravity.CENTER_VERTICAL | Gravity.BOTTOM; windowManagerParams.x = 0; windowManagerParams.y = 0; windowManagerParams.width = LayoutParams.WRAP_CONTENT; windowManagerParams.height = LayoutParams.WRAP_CONTENT; windowManager.addView(floatView, windowManagerParams); }
private void initPopupMenuBg(final Activity context) { LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.defaultpopupmenubg, null); mPopupMenuBg = new PopupWindow(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, false); mPopupMenuBg.setFocusable(false); mPopupMenuBg.setOutsideTouchable(false); mPopupMenuBg.setBackgroundDrawable(null); mPopupMenuBg.setAnimationStyle(R.style.default_popup_menu_bg_style); mPopupMenuBg.update(); }
void setupButtonViews(Context context) { mButtonView = (Button) getInflater().inflate(R.layout.accessory_button, null); mButtonView.setClickable(true); int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, context.getResources().getDisplayMetrics()); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, height); getAccessoryView().removeAllViews(); getAccessoryView().addView(mButtonView, params); }
@SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_story); Intent intent = getIntent(); int storyId = Integer.parseInt(intent.getStringExtra("storyId")); db = new DBHandler(); story = db.get_story(storyId); TextView textView = (TextView) findViewById(R.id.story_name_view); textView.setText(story.getName()); LinearLayout ll = (LinearLayout) findViewById(R.id.view_story_scroll); ArrayList<Photo> photos = db.get_photos(storyId); for (int i = 0; i < photos.size(); i++) { LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(10,10,10,10); ImageView imView = new ImageView(this); String imgUrl = photos.get(i).getUrl(); Bitmap bm = BitmapFactory.decodeFile(imgUrl); imView.setImageBitmap(bm); imView.setLayoutParams(lp); ll.addView(imView); TextView tView = new TextView(this); String imgComment = photos.get(i).getComment(); tView.setText(imgComment); tView.setGravity(Gravity.CENTER); tView.setLayoutParams(lp); ll.addView(tView); } Button share = (Button) findViewById(R.id.share); share.setOnClickListener(shareListener); }
@SuppressWarnings("unused") private void showPopupWindow() { View view = View.inflate(this, R.layout.popuwindow, null); final PopupWindow popupWindow = new PopupWindow(view); popupWindow.setHeight(LayoutParams.WRAP_CONTENT); popupWindow.setWidth(LayoutParams.WRAP_CONTENT); // TODO 还未做完 }
@Override //This activity is built dynamic protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); LinearLayout linearLayout= new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setBackgroundColor(Color.BLACK); linearLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); setContentView(linearLayout); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setFilterBitmap(true); paint.setDither(true); //ImageView Setup ImageView imageView = new ImageView(this); imageView.setImageResource(R.drawable.profile); linearLayout.addView(imageView); imageView.setX(0); scaleImage(imageView, 150); // in dp TextView body = new TextView(this); String bodyText = "Selfies ugh lomo, small batch bicycle rights distillery Helvetica cliche meggings sartorial Wes Anderson chillwave mustache. Before they sold out post-ironic ennui, cray meh gentrify DIY pork belly cred. Kogi jean shorts brunch High Life irony Schlitz. Truffaut asymmetrical Williamsburg, you probably haven't heard of them fanny pack bicycle rights Pitchfork Tonx Tumblr PBR&B selvage. Cardigan keffiyeh leggings readymade sartorial chambray. Neutra chillwave leggings Pitchfork. XOXO salvia quinoa, selfies hella asymmetrical ennui letterpress Helvetica lomo. Helvetica pickled twee, messenger bag Vice jean shorts pork belly. <p> Gluten-free four loko synth, XOXO retro Pitchfork food truck fixie. Direct trade sriracha chia church-key Etsy Tumblr. Retro literally PBR&B fixie, paleo hashtag whatever messenger bag craft beer scenester. Godard cray plaid actually. Flexitarian Godard Vice ennui gluten-free artisan. Twee cred +1 stumptown XOXO. Sriracha hella squid, PBR&B cardigan fashion axe aesthetic narwhal twee you probably haven't heard of them polaroid ethical. Mlkshk fingerstache lomo High Life ethical meggings."; body.setText(Html.fromHtml(bodyText)); body.setTextColor(Color.WHITE); linearLayout.addView(body); TextView link = new TextView(this); String linkText = "Visit <a href='http://donothingbox.com'>DoNothingBox</a> web page. which may not even be live yet . . . works in progress . . . "; link.setTextColor(Color.WHITE); link.setText(Html.fromHtml(linkText)); link.setMovementMethod(LinkMovementMethod.getInstance()); linearLayout.addView(link); }
private void scaleImage(ImageView view, int boundBoxInDp) { // Get the ImageView and its bitmap Drawable drawing = view.getDrawable(); Bitmap bitmap = ((BitmapDrawable)drawing).getBitmap(); // Get current dimensions int width = bitmap.getWidth(); int height = bitmap.getHeight(); // Determine how much to scale: the dimension requiring less scaling is // closer to the its side. This way the image always stays inside your // bounding box AND either x/y axis touches it. float xScale = ((float) boundBoxInDp) / width; float yScale = ((float) boundBoxInDp) / height; float scale = (xScale <= yScale) ? xScale : yScale; // Create a matrix for the scaling and add the scaling data Matrix matrix = new Matrix(); matrix.postScale(scale, scale); // Create a new bitmap and convert it to a format understood by the ImageView Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); BitmapDrawable result = new BitmapDrawable(scaledBitmap); width = scaledBitmap.getWidth(); height = scaledBitmap.getHeight(); // Apply the scaled bitmap view.setImageDrawable(result); // Now change ImageView's dimensions to match the scaled image LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.width = width; params.height = height; view.setLayoutParams(params); }