List of usage examples for android.widget LinearLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:org.openremote.android.console.AppSettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setTitle(R.string.settings);//from w w w. j a v a 2s .c o m this.autoMode = AppSettingsModel.isAutoMode(AppSettingsActivity.this); // The main layout contains all application configuration items. LinearLayout mainLayout = new LinearLayout(this); mainLayout .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mainLayout.setOrientation(LinearLayout.VERTICAL); mainLayout.setBackgroundColor(0); mainLayout.setTag(R.string.settings); loadingPanelProgress = new ProgressDialog(this); // The scroll view contains appSettingsView, and make the appSettingsView can be scrolled. ScrollView scroll = new ScrollView(this); scroll.setVerticalScrollBarEnabled(true); scroll.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1)); appSettingsView = new LinearLayout(this); appSettingsView .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); appSettingsView.setOrientation(LinearLayout.VERTICAL); appSettingsView.addView(createAutoLayout()); appSettingsView.addView(createChooseControllerLabel()); currentServer = ""; if (autoMode) { appSettingsView.addView(constructAutoServersView()); } else { appSettingsView.addView(constructCustomServersView()); } appSettingsView.addView(createChoosePanelLabel()); panelSelectSpinnerView = new PanelSelectSpinnerView(this); appSettingsView.addView(panelSelectSpinnerView); appSettingsView.addView(createCacheText()); appSettingsView.addView(createClearImageCacheButton()); appSettingsView.addView(createSSLLayout()); scroll.addView(appSettingsView); mainLayout.addView(scroll); mainLayout.addView(createDoneAndCancelLayout()); setContentView(mainLayout); initSSLState(); addOnclickListenerOnDoneButton(); addOnclickListenerOnCancelButton(); progressLayout = (LinearLayout) findViewById(R.id.choose_controller_progress); }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.OrgProfile.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); Intent i = this.getIntent(); Bundle b = i.getExtras();/* w ww.j ava 2 s . c o m*/ __keys = new CipherSuit[3]; __keys[KEY_IDX_ECDSA_BIG] = newCipherSuit(Cipher.ECDSA, Cipher.SHA384, ECDSA.P_521); __keys[KEY_IDX_ECDSA] = newCipherSuit(Cipher.ECDSA, Cipher.SHA1, ECDSA.P_256); __keys[KEY_IDX_RSA] = newCipherSuit(Cipher.RSA, Cipher.SHA512, 1024); // top panel setting organization_position = b.getInt(Orgs.O_ID); organization_LID = b.getString(Orgs.O_LID); organization_GIDH = b.getString(Orgs.O_GIDH); oLID = Util.lval(organization_LID, -1); if (oLID <= 0) return; this.org = D_Organization.getOrgByLID(oLID, true, false); if (org == null) return; try { Identity crt_identity = Identity.getCurrentConstituentIdentity(); if (crt_identity == null) { Log.d(TAG, "No identity"); } else constituent_LID = net.ddp2p.common.config.Identity.getDefaultConstituentIDForOrg(oLID); } catch (P2PDDSQLException e1) { e1.printStackTrace(); } if (constituent_LID > 0) { constituent = D_Constituent.getConstByLID(constituent_LID, true, false); Log.d(TAG, "Got const: " + constituent); } setContentView(R.layout.org_profile); forename = (EditText) findViewById(R.id.profile_furname); surname = (EditText) findViewById(R.id.profile_surname); neiborhood = (Button) findViewById(R.id.profile_neiborhood); submit = (Button) findViewById(R.id.submit_profile); submit_new = (Button) findViewById(R.id.submit_profile_new); if (constituent == null) submit.setVisibility(Button.GONE); else submit.setVisibility(Button.VISIBLE); keys = (Spinner) findViewById(R.id.profile_keys); hasRightToVote = (CheckedTextView) findViewById(R.id.profile_hasRightToVote); email = (EditText) findViewById(R.id.profile_email); slogan = (EditText) findViewById(R.id.profile_slogan); slogan.setActivated(false); profilePic = (TextView) findViewById(R.id.profile_picture); profilePicImg = (ImageView) findViewById(R.id.profile_picture_img); // eligibility = (Spinner) findViewById(R.id.profile_eligibility); if (constituent != null) { forename.setText(constituent.getForename()); surname.setText(constituent.getSurname()); hasRightToVote.setChecked(Util.ival(constituent.getWeight(), 0) > 0); email.setText(constituent.getEmail()); slogan.setText(constituent.getSlogan()); } custom_fields = (LinearLayout) findViewById(R.id.profile_view); custom_index = 8; // custom_fields = (LinearLayout) findViewById(R.id.profile_custom); // custom_index = 0; custom_params = org.params.orgParam; if (custom_params == null || custom_params.length == 0) { custom_params = new D_OrgParam[0];// 3 /* * custom_params[0] = new D_OrgParam(); custom_params[0].label = * "School"; custom_params[0].entry_size = 5; custom_params[1] = new * D_OrgParam(); custom_params[1].label = "Street"; custom_params[2] * = new D_OrgParam(); custom_params[2].label = "Year"; * custom_params[2].list_of_values = new * String[]{"2010","2011","2012"}; */ } D_FieldValue[] field_values = null; if (constituent != null && constituent.address != null) field_values = constituent.address; for (int crt_field = 0; crt_field < custom_params.length; crt_field++) { D_OrgParam field = custom_params[crt_field]; LinearLayout custom_entry = new LinearLayout(this); custom_entry.setOrientation(LinearLayout.HORIZONTAL); custom_entry.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); TextView custom_label = new TextView(this); custom_label.setText(field.label); custom_entry.addView(custom_label); if (field.list_of_values != null && field.list_of_values.length > 0) { Log.d(TAG, "spinner:" + field); Spinner custom_spin = new Spinner(this); ArrayAdapter<String> custom_spin_Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, field.list_of_values); custom_spin_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); custom_spin.setAdapter(custom_spin_Adapter); custom_entry.addView(custom_spin); D_FieldValue fv = locateFV(field_values, field); if (fv != null) { int position = 0; for (int k = 0; k <= field.list_of_values.length; k++) { if (Util.equalStrings_null_or_not(field.list_of_values[k], fv.value)) { position = k; break; } } custom_spin.setSelection(position); } } else { Log.d(TAG, "edit: " + field); EditText edit_text = new EditText(this); edit_text.setText(field.default_value); edit_text.setInputType(InputType.TYPE_CLASS_TEXT); if (field.entry_size > 0) edit_text.setMinimumWidth(field.entry_size * 60); Log.d(TAG, "edit: size=" + field.entry_size); custom_entry.addView(edit_text); // Button child = new Button(this); // child.setText("Test"); D_FieldValue fv = locateFV(field_values, field); if (fv != null) edit_text.setText(fv.value); } custom_fields.addView(custom_entry, custom_index++); } ArrayAdapter<String> keysAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m); keysAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); keys.setAdapter(keysAdapter); keys.setOnItemSelectedListener(new KeysListener()); if (constituent != null) { SK sk = constituent.getSK(); if (sk != null) { Cipher cipher = Cipher.getCipher(sk, null); if (cipher instanceof net.ddp2p.ciphersuits.RSA) { keys.setSelection(KEY_IDX_RSA, true); } if (cipher instanceof net.ddp2p.ciphersuits.ECDSA) { ECDSA ecdsa = (ECDSA) cipher; CipherSuit e = ECDSA.getCipherSuite(ecdsa.getPK()); if (e.hash_alg == Cipher.SHA1) { keys.setSelection(KEY_IDX_ECDSA, true); } else { keys.setSelection(KEY_IDX_ECDSA_BIG, true); } } } } ArrayAdapter<String> eligibilityAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m); eligibilityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // eligibility.setAdapter(eligibilityAdapter); // eligibility.setOnItemSelectedListener(new EligibilityListener()); hasRightToVote.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { hasRightToVote.setChecked(!hasRightToVote.isChecked()); } }); setProfilePhoto = (ImageView) findViewById(R.id.org_profile_set_profile_photo); /*TODO this part only make the whole stuff slow if (constituent_LID > 0) { constituent = D_Constituent.getConstByLID(constituent_LID, true, true); Log.d(TAG, "Got const: " + constituent); } */ /* boolean gotIcon = false; if (constituent != null) { if (constituent.getPicture() != null) { byte[] icon = constituent.getPicture(); Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length - 1); setProfilePhoto.setImageBitmap(bmp); gotIcon = true; } if (!gotIcon) { int imgPath = R.drawable.constitutent_person_icon; Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); setProfilePhoto.setImageBitmap(bmp); } } else { int imgPath = R.drawable.constitutent_person_icon; Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); setProfilePhoto.setImageBitmap(bmp); } setProfilePhoto.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT < 19) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, SELECT_PROFILE_PHOTO); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); startActivityForResult(intent, SELECT_PPROFILE_PHOTO_KITKAT); } } });*/ submit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String _forename = forename.getText().toString(); String _surname = surname.getText().toString(); int _keys = OrgProfile._selectedKey; boolean rightToVote = hasRightToVote.isChecked(); String _weight = rightToVote ? "1" : "0"; String _email = email.getText().toString(); String _slogan = slogan.getText().toString(); boolean external = false; if (constituent == null) { D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID, external, _weight, _slogan, OrgProfile.__keys[_keys].cipher, OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null); Log.d(TAG, "saved constituent=" + new_const.getNameFull()); try { // Identity.DEBUG = true; Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID); } catch (P2PDDSQLException e) { e.printStackTrace(); } Log.d(TAG, "saved new constituent=" + new_const); constituent = new_const; } else { constituent = D_Constituent.getConstByConst_Keep(constituent); constituent.setEmail(_email); constituent.setForename(_forename); constituent.setSurname(_surname); constituent.setWeight(rightToVote); constituent.setSlogan(_slogan); constituent.setExternal(false); constituent.setCreationDate(); constituent.sign(); if (constituent.dirty_any()) constituent.storeRequest(); constituent.releaseReference(); Log.d(TAG, "saved constituent=" + constituent); try { // Identity.DEBUG = true; Identity.setCurrentConstituentForOrg(constituent.getLID(), oLID); } catch (P2PDDSQLException e) { e.printStackTrace(); } Log.d(TAG, "saved constituent=" + constituent.getLID() + " oLID=" + oLID); } if (constituent != null) { constituent = D_Constituent.getConstByConst_Keep(constituent); if (constituent != null) { if (constituent.getSK() != null) { constituent.setPicture(byteIcon); constituent.setCreationDate(); constituent.sign(); constituent.storeRequest(); constituent.releaseReference(); Log.d(TAG, "saved constituent pic: " + constituent.getPicture()); } } } if (!org.getBroadcasted()) { D_Organization _org = D_Organization.getOrgByOrg_Keep(org); if (_org != null) { _org.setBroadcasting(true); if (_org.dirty_any()) _org.storeRequest(); _org.releaseReference(); org = _org; } } Log.d(TAG, "saved constituent pic: " + constituent.getPicture()); Log.d(TAG, "saved constituent Done"); finish(); } }); submit_new.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String _forename = forename.getText().toString(); String _surname = surname.getText().toString(); int _keys = OrgProfile._selectedKey; boolean rightToVote = hasRightToVote.isChecked(); String _weight = rightToVote ? "1" : "0"; String _email = email.getText().toString(); String _slogan = slogan.getText().toString(); boolean external = false; D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID, external, _weight, _slogan, OrgProfile.__keys[_keys].cipher, OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null); Log.d(TAG, "saved constituent=" + new_const.getNameFull()); try { // Identity.DEBUG = true; Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID); Log.d("CONST", "No Set: oLID=" + oLID + " c=" + new_const.getLID()); } catch (P2PDDSQLException e) { e.printStackTrace(); } constituent = new_const; constituent_LID = new_const.getLID(); if (constituent_LID > 0) { constituent = D_Constituent.getConstByLID(constituent_LID, true, true); Log.d(TAG, "Got const: " + constituent); } if (constituent != null) { if (constituent.getSK() != null) { constituent.setPicture(byteIcon); constituent.setCreationDate(); constituent.sign(); constituent.storeRequest(); constituent.releaseReference(); Log.d(TAG, "saved constituent pic: " + constituent.getPicture()); } } if (!org.getBroadcasted()) { D_Organization _org = D_Organization.getOrgByOrg_Keep(org); if (_org != null) { _org.setBroadcasting(true); if (_org.dirty_any()) _org.storeRequest(); _org.releaseReference(); org = _org; } } Log.d(TAG, "saved constituent=" + new_const); finish(); } }); }
From source file:com.example.damerap_ver1.IntroVideoActivity.java
/** * Create the view in which the video will be rendered. *//*www. j a v a2 s .c o m*/ 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.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_PT, 8); mProgressMessage.setText("..."); lRelLayout.addView(mProgressMessage); }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // it removes the title from the actionbar(more space for icons?) // this.getActionBar().setDisplayShowTitleEnabled(false); pixels5 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); LinearLayout parent = new LinearLayout(this); parent.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); parent.setOrientation(LinearLayout.VERTICAL); LinearLayout scrollViewParent = new LinearLayout(this); scrollViewParent.setLayoutParams(/*from w w w. j a v a 2 s. c o m*/ new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); scrollViewParent.setOrientation(LinearLayout.HORIZONTAL); HorizontalScrollView predictionsHorizontalScrollView = new HorizontalScrollView(this); //predictionsHorizontalScrollView.setLayoutParams(new ViewGroup.LayoutParams()); predictions = new LinearLayout(this); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); params.gravity = Gravity.CENTER_VERTICAL; predictions.setLayoutParams(params); predictions.setOrientation(LinearLayout.HORIZONTAL); resetPredictionsView(predictions, true); predictionsHorizontalScrollView.addView(predictions); saveButton = new Button(this); saveButton.setText("Send Feedback"); predictionsHorizontalScrollView.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 10.0f)); saveButton.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); saveButton.setVisibility(View.INVISIBLE); FrameLayout frameLayout = new FrameLayout(this); frameLayout .setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); frameLayout.addView(saveButton); loader = new ProgressBar(this); loader.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); loader.setIndeterminate(true); loader.setVisibility(ProgressBar.INVISIBLE); frameLayout.addView(loader); scrollViewParent.addView(predictionsHorizontalScrollView); scrollViewParent.addView(frameLayout); contentView = new MyView(this); parent.addView(scrollViewParent); parent.addView(contentView); setContentView(parent); otherLabelOnClickListener = new View.OnClickListener() { @Override public void onClick(View view) { Log.e("Clicked", "Other Label label '" + (String) view.getTag() + "'"); sendScreenshot(false, feedbackType, (String) view.getTag()); } }; mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(DEFAULT_BRUSH_SIZE); // Where did these magic numbers come from? What do they mean? Can I change them? ~TheOpenSourceNinja // Absolutely random numbers in order to see the emboss. asd! ~Valerio mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL); if (isFirstTime()) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.app_name); alert.setMessage(R.string.app_description); alert.setNegativeButton(R.string.continue_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT) .show(); } }); alert.show(); } else { Toast.makeText(getApplicationContext(), R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show(); } loadFromIntents(); }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * Hide the filter statusbar.// w ww . j a v a2 s . c om */ public void hideFilterStatusbar() { LinearLayout filterBar = (LinearLayout) findViewById(R.id.filterStatus); ViewGroup.LayoutParams params = filterBar.getLayoutParams(); params.height = 0; filterBar.setLayoutParams(new LinearLayout.LayoutParams(params)); }
From source file:org.telegram.ui.LanguageSelectActivity.java
@Override public View createView(Context context) { searching = false;/*www. j a va2 s . co m*/ searchWas = false; actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("Language", R.string.Language)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true) .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; } @Override public void onSearchCollapse() { search(null); searching = false; searchWas = false; if (listView != null) { emptyTextView.setVisibility(View.GONE); listView.setAdapter(listAdapter); } } @Override public void onTextChanged(EditText editText) { String text = editText.getText().toString(); search(text); if (text.length() != 0) { searchWas = true; if (listView != null) { listView.setAdapter(searchListViewAdapter); } } } }); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); listAdapter = new ListAdapter(context); searchListViewAdapter = new SearchAdapter(context); fragmentView = new FrameLayout(context); fragmentView.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); LinearLayout emptyTextLayout = new LinearLayout(context); emptyTextLayout.setVisibility(View.INVISIBLE); emptyTextLayout.setOrientation(LinearLayout.VERTICAL); ((FrameLayout) fragmentView).addView(emptyTextLayout); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; emptyTextLayout.setLayoutParams(layoutParams); emptyTextLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); emptyTextView = new TextView(context); emptyTextView.setTextColor(0xff808080); emptyTextView.setTextSize(20); emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult)); emptyTextLayout.addView(emptyTextView); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; emptyTextView.setLayoutParams(layoutParams1); FrameLayout frameLayout = new FrameLayout(context); emptyTextLayout.addView(frameLayout); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams1.width = LayoutHelper.MATCH_PARENT; layoutParams1.height = LayoutHelper.MATCH_PARENT; layoutParams1.weight = 0.5f; frameLayout.setLayoutParams(layoutParams1); listView = new ListView(context); listView.setEmptyView(emptyTextLayout); listView.setVerticalScrollBarEnabled(false); listView.setDivider(null); listView.setDividerHeight(0); listView.setAdapter(listAdapter); ((FrameLayout) fragmentView).addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { LocaleController.LocaleInfo localeInfo = null; if (searching && searchWas) { if (i >= 0 && i < searchResult.size()) { localeInfo = searchResult.get(i); } } else { if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) { localeInfo = LocaleController.getInstance().sortedLanguages.get(i); } } if (localeInfo != null) { LocaleController.getInstance().applyLanguage(localeInfo, true); parentLayout.rebuildAllFragmentViews(false); } finishFragment(); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { LocaleController.LocaleInfo localeInfo = null; if (searching && searchWas) { if (i >= 0 && i < searchResult.size()) { localeInfo = searchResult.get(i); } } else { if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) { localeInfo = LocaleController.getInstance().sortedLanguages.get(i); } } if (localeInfo == null || localeInfo.pathToFile == null || getParentActivity() == null) { return false; } final LocaleController.LocaleInfo finalLocaleInfo = localeInfo; AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) { if (searchResult != null) { searchResult.remove(finalLocaleInfo); } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } if (searchListViewAdapter != null) { searchListViewAdapter.notifyDataSetChanged(); } } } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); return true; } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); return fragmentView; }
From source file:roommateapp.info.droid.ActivityBuilding.java
/** * Display the filter statusbar./*from w ww. j a va 2 s . c o m*/ * * @param message to be displayed */ public void showFilterStatusbar(String message) { // Set message TextView filterText = (TextView) findViewById(R.id.filterMsgText); filterText.setText(message); // Make statusbar visible LinearLayout filterBar = (LinearLayout) findViewById(R.id.filterStatus); ViewGroup.LayoutParams params = filterBar.getLayoutParams(); params.height = ViewGroup.LayoutParams.WRAP_CONTENT; filterBar.setLayoutParams(new LinearLayout.LayoutParams(params)); }
From source file:com.aware.Aware.java
/** * Given a plugin's package name, fetch the context card for reuse. * @param context: application context/*ww w .j av a 2 s . c o m*/ * @param package_name: plugin's package name * @return View for reuse (instance of LinearLayout) */ public static View getContextCard(final Context context, final String package_name) { if (!isClassAvailable(context, package_name, "ContextCard")) { return null; } String ui_class = package_name + ".ContextCard"; LinearLayout card = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); card.setLayoutParams(params); card.setOrientation(LinearLayout.VERTICAL); try { Context packageContext = context.createPackageContext(package_name, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); Class<?> fragment_loader = packageContext.getClassLoader().loadClass(ui_class); Object fragment = fragment_loader.newInstance(); Method[] allMethods = fragment_loader.getDeclaredMethods(); Method m = null; for (Method mItem : allMethods) { String mName = mItem.getName(); if (mName.contains("getContextCard")) { mItem.setAccessible(true); m = mItem; break; } } View ui = (View) m.invoke(fragment, packageContext); if (ui != null) { //Check if plugin has settings. If it does, tapping the card shows the settings if (isClassAvailable(context, package_name, "Settings")) { ui.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); open_settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(open_settings); } }); } //Set card look-n-feel ui.setBackgroundColor(Color.WHITE); ui.setPadding(20, 20, 20, 20); card.addView(ui); LinearLayout shadow = new LinearLayout(context); LayoutParams params_shadow = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params_shadow.setMargins(0, 0, 0, 10); shadow.setBackgroundColor(context.getResources().getColor(R.color.card_shadow)); shadow.setMinimumHeight(5); shadow.setLayoutParams(params_shadow); card.addView(shadow); return card; } else { return null; } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } return null; }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * It contains a list view to display custom servers, * "Add" button to add custom server, "Delete" button to delete custom server. * The custom servers would be saved in customServers.xml. If click a list item, it would be saved as current server. * //from w ww . j a v a 2 s . c o m * @return the linear layout */ private LinearLayout constructCustomServersView() { LinearLayout custumeView = new LinearLayout(this); custumeView.setOrientation(LinearLayout.VERTICAL); custumeView.setPadding(20, 5, 5, 0); custumeView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ArrayList<String> customServers = new ArrayList<String>(); initCustomServersFromFile(customServers); RelativeLayout buttonsView = new RelativeLayout(this); buttonsView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 80)); Button addServer = new Button(this); addServer.setWidth(80); RelativeLayout.LayoutParams addServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); addServerLayout.addRule(RelativeLayout.CENTER_HORIZONTAL); addServer.setLayoutParams(addServerLayout); addServer.setText("Add"); addServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(AppSettingsActivity.this, AddServerActivity.class); startActivityForResult(intent, Constants.REQUEST_CODE); } }); Button deleteServer = new Button(this); deleteServer.setWidth(80); RelativeLayout.LayoutParams deleteServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); deleteServerLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); deleteServer.setLayoutParams(deleteServerLayout); deleteServer.setText("Delete"); deleteServer.setOnClickListener(new OnClickListener() { @SuppressWarnings("unchecked") public void onClick(View v) { int checkedPosition = customListView.getCheckedItemPosition(); if (!(checkedPosition == ListView.INVALID_POSITION)) { customListView.setItemChecked(checkedPosition, false); ((ArrayAdapter<String>) customListView.getAdapter()) .remove(customListView.getItemAtPosition(checkedPosition).toString()); currentServer = ""; AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); } } }); buttonsView.addView(addServer); buttonsView.addView(deleteServer); customListView = new ListView(this); customListView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); customListView.setCacheColorHint(0); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, customServers); customListView.setAdapter(serverListAdapter); customListView.setItemsCanFocus(true); customListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); if (currentCustomServerIndex != -1) { customListView.setItemChecked(currentCustomServerIndex, true); currentServer = (String) customListView.getItemAtPosition(currentCustomServerIndex); } customListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); requestPanelList(); checkAuthentication(); requestAccess(); } }); custumeView.addView(customListView); custumeView.addView(buttonsView); requestPanelList(); checkAuthentication(); requestAccess(); return custumeView; }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
private LinearLayout getCenteredRowText(Context context, String text, float layoutWeightSum, boolean largeText, float textViewWeight) { final LinearLayout inner = new LinearLayout(context); final TableRow.LayoutParams innerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); innerParams.span = itemsPerInnerRow; inner.setLayoutParams(innerParams); inner.setWeightSum(layoutWeightSum); inner.setBackgroundResource(R.drawable.cell_shape); final TextView nameTextView = new TextView(context); nameTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, textViewWeight)); nameTextView.setTextAppearance(context, largeText ? android.R.style.TextAppearance_Large : android.R.style.TextAppearance_Medium); nameTextView.setText(text);/*from ww w . jav a 2 s. c o m*/ nameTextView.setGravity(Gravity.CENTER); inner.addView(nameTextView); return inner; }