List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*www. j ava2 s . c o m*/ byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } LinearLayout inner = new LinearLayout(context); inner.setLayoutParams(CommonLayouts.FULL_WIDTH); inner.setOrientation(LinearLayout.HORIZONTAL); frame.addView(inner); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); BitmapFactory bf = new BitmapFactory(); imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length)); inner.addView(imageView); ImageView iconView = new ImageView(context); iconView.setImageResource(R.drawable.play); iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); inner.addView(iconView); }
From source file:com.matthewtamlin.sliding_intro_screen_manual_testing.TestPageLock.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create a layout to display the control buttons over the ViewPager final LinearLayout controlButtonHolder = new LinearLayout(this); controlButtonHolder.setOrientation(LinearLayout.HORIZONTAL); getRootView().addView(controlButtonHolder); // Create a layout to display buttons for changing the page final LinearLayout pageChangeButtonHolder = new LinearLayout(this); pageChangeButtonHolder.setOrientation(LinearLayout.VERTICAL); controlButtonHolder.addView(pageChangeButtonHolder); // Create a layout to display buttons for locking the ViewPager final LinearLayout pageLockButtonHolder = new LinearLayout(this); pageLockButtonHolder.setOrientation(LinearLayout.VERTICAL); controlButtonHolder.addView(pageLockButtonHolder); // Create the button for changing the page pageChangeButtonHolder.addView(createGoToFirstPageButton()); pageChangeButtonHolder.addView(createGoToLastPageButton()); pageChangeButtonHolder.addView(createGoToPreviousPageButton()); pageChangeButtonHolder.addView(createGoToNextPageButton()); pageChangeButtonHolder.addView(createGoToSpecificPageButton(SPECIFIC_PAGE)); // Create the buttons for locking the page pageLockButtonHolder.addView(createLockTouchButton()); pageLockButtonHolder.addView(createLockCommandButton()); pageLockButtonHolder.addView(createLockAllButton()); pageLockButtonHolder.addView(createUnlockButton()); }
From source file:com.fuse.qreader.BarcodeCaptureActivity.java
/** * Initializes the UI and creates the detector pipeline. *//*from w w w. j a va 2s .c o m*/ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); LinearLayout linLayout = new LinearLayout(this); linLayout.setOrientation(LinearLayout.VERTICAL); LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mPreview = new CameraSourcePreview(this); mGraphicOverlay = new GraphicOverlay<BarcodeGraphic>(this); mPreview.addView(mGraphicOverlay); linLayout.addView(mPreview); setContentView(linLayout, linLayoutParam); // Check for the camera permission before accessing the camera. If the // permission is not granted yet, request permission. int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA); if (rc == PackageManager.PERMISSION_GRANTED) { createCameraSource(true); } else { requestCameraPermission(); } }
From source file:pl.bcichecki.rms.client.android.dialogs.RemindPasswordDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { context = getActivity();//from w ww . j av a 2s . co m AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.dialog_remind_password_title)); builder.setMessage(getString(R.string.dialog_remind_password_message)); final LinearLayout layout = new LinearLayout(getActivity()); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER_HORIZONTAL); int space = (int) AppUtils.convertDpToPixel(getActivity(), 16); layout.setPadding(space, 0, space, 0); final EditText usernameEditText = new EditText(getActivity()); usernameEditText.setHint(getString(R.string.dialog_remind_password_enter_username_hint)); usernameEditText.setMaxLines(1); usernameEditText.setSingleLine(); usernameEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); usernameEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { usernameEditText.setError(null); } }); layout.addView(usernameEditText); builder.setView(layout); builder.setPositiveButton(getString(R.string.dialog_remind_password_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { return; } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }); builder.setCancelable(false); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { utilitiesRestClient = new UtilitiesRestClient(getActivity(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!AppUtils.checkInternetConnection(getActivity())) { Log.d(TAG, "There is NO network connected!"); return; } usernameEditText.setError(null); if (StringUtils.isBlank(usernameEditText.getText().toString())) { usernameEditText.setError(getString(R.string.dialog_remind_password_field_required)); return; } final String username = usernameEditText.getText().toString(); utilitiesRestClient.forgotPassword(username, new AsyncHttpResponseHandler() { @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Reminding password failed. [error=" + error + ", content=" + content + "]"); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_failed), Toast.LENGTH_LONG); } @Override public void onFinish() { positiveButton.setEnabled(true); } @Override public void onStart() { Log.d(TAG, "Reminding password for user: " + username); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_in_progress), Toast.LENGTH_SHORT); positiveButton.setEnabled(false); } @Override public void onSuccess(int statusCode, String content) { Log.d(TAG, "Reminding password success."); AppUtils.showCenteredToast(context, getString(R.string.dialog_remind_password_recovery_successful), Toast.LENGTH_SHORT); dialog.dismiss(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { cancelRequests(); dialog.dismiss(); } }); } }); return dialog; }
From source file:org.quantumbadger.redreader.activities.AlbumListingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PrefsUtility.applyTheme(this); OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album)); if (getActionBar() != null) { getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); }//from w ww . j a v a 2 s . c om final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; if (solidblack) getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK)); final Intent intent = getIntent(); mUrl = intent.getDataString(); if (mUrl == null) { finish(); return; } final Matcher matchImgur = LinkHandler.imgurAlbumPattern.matcher(mUrl); final String albumId; if (matchImgur.find()) { albumId = matchImgur.group(2); } else { Log.e("AlbumListingActivity", "URL match failed"); revertToWeb(); return; } Log.i("AlbumListingActivity", "Loading URL " + mUrl + ", album id " + albumId); final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); progressBar.setIndeterminate(true); final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(progressBar); ImgurAPI.getAlbumInfo(this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetAlbumInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "getAlbumInfo call failed: " + type); if (status != null) Log.e("AlbumListingActivity", "status was: " + status.toString()); if (t != null) Log.e("AlbumListingActivity", "exception was: ", t); // It might be a single image, not an album if (status == null) { revertToWeb(); return; } ImgurAPI.getImageInfo(AlbumListingActivity.this, albumId, Constants.Priority.IMAGE_VIEW, 0, new GetImageInfoListener() { @Override public void onFailure(final RequestFailureType type, final Throwable t, final StatusLine status, final String readableMessage) { Log.e("AlbumListingActivity", "Image info request also failed: " + type); revertToWeb(); } @Override public void onSuccess(final ImageInfo info) { Log.i("AlbumListingActivity", "Link was actually an image."); LinkHandler.onLinkClicked(AlbumListingActivity.this, info.urlOriginal); finish(); } @Override public void onNotAnImage() { Log.i("AlbumListingActivity", "Not an image either"); revertToWeb(); } }); } @Override public void onSuccess(final ImgurAPI.AlbumInfo info) { Log.i("AlbumListingActivity", "Got album, " + info.images.size() + " image(s)"); AndroidApi.UI_THREAD_HANDLER.post(new Runnable() { @Override public void run() { if (info.title != null && !info.title.trim().isEmpty()) { OptionsMenuUtility.fixActionBar(AlbumListingActivity.this, getString(R.string.imgur_album) + ": " + info.title); } layout.removeAllViews(); final ListView listView = new ListView(AlbumListingActivity.this); listView.setAdapter(new AlbumAdapter(info)); layout.addView(listView); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { LinkHandler.onLinkClicked(AlbumListingActivity.this, info.images.get(position).urlOriginal, false, null, info, position); } }); } }); } }); setContentView(layout); }
From source file:de.vanita5.twittnuker.fragment.support.BasePullToRefreshListFragment.java
/** * 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 ListView 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./* www . j a v a 2s .c o m*/ * <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(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final 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.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final RefreshNowListView lv = new RefreshNowListView(getActivity()); lv.setId(android.R.id.list); lv.setOverScrollMode(View.OVER_SCROLL_NEVER); lv.setDrawSelectorOnTop(false); lv.setOnRefreshListener(this); lv.setConfig(ThemeUtils.buildRefreshNowConfig(context)); lv.setOnTouchListener(this); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final RefreshNowProgressIndicator indicator = new RefreshNowProgressIndicator(context); indicator.setConfig(ThemeUtils.buildRefreshIndicatorConfig(context)); final int indicatorHeight = Math.round(3 * getResources().getDisplayMetrics().density); lframe.addView(indicator, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, indicatorHeight, Gravity.TOP)); lv.setRefreshIndicatorView(indicator); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java
public void getLegalInfo(View v) { String photoId = v.getTag() + ""; ImageRestClient.get().getInfoFromImageId(photoId, new Callback<ImageService.ImageInfoWrapper>() { @Override/*from ww w . j a v a2s . c o m*/ public void success(ImageService.ImageInfoWrapper imageInfoWrapper, Response response) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity); ScrollView wrapper = new ScrollView(MainActivity.activity); LinearLayout infoLayout = new LinearLayout(MainActivity.activity); infoLayout.setOrientation(LinearLayout.VERTICAL); infoLayout.setPadding(35, 35, 35, 35); TextView imageOwner = new TextView(MainActivity.activity); imageOwner.setText(Html.fromHtml("<b>Image By: </b>" + imageInfoWrapper.photo.owner.username)); if (imageInfoWrapper.photo.owner.realname.length() > 0) { imageOwner.setText(imageOwner.getText() + " (" + imageInfoWrapper.photo.owner.realname + ")"); } infoLayout.addView(imageOwner); if (getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)).length() > 0) { TextView licenseLink = new TextView(MainActivity.activity); licenseLink.setText(Html .fromHtml("<a href=\"" + getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)) + "\"><b>Licensing</b></a>")); licenseLink.setMovementMethod(LinkMovementMethod.getInstance()); infoLayout.addView(licenseLink); } if (imageInfoWrapper.photo.urls.url.size() > 0) { TextView imageLink = new TextView(MainActivity.activity); imageLink.setText(Html.fromHtml("<a href=\"" + imageInfoWrapper.photo.urls.url.get(0)._content + "\"><b>Image Link</b></a>")); imageLink.setMovementMethod(LinkMovementMethod.getInstance()); infoLayout.addView(imageLink); } if (imageInfoWrapper.photo.title._content.length() > 0) { TextView photoTitle = new TextView(MainActivity.activity); photoTitle .setText(Html.fromHtml("<b>Image Title: </b>" + imageInfoWrapper.photo.title._content)); infoLayout.addView(photoTitle); } if (imageInfoWrapper.photo.description._content.length() > 0) { TextView description = new TextView(MainActivity.activity); description.setText(Html .fromHtml("<b>Image Description: </b>" + imageInfoWrapper.photo.description._content)); infoLayout.addView(description); } TextView contact = new TextView(MainActivity.activity); contact.setText( Html.fromHtml("<br><i>To remove this photo, please email pcorpsconnect@gmail.com</i>")); infoLayout.addView(contact); wrapper.addView(infoLayout); builder.setTitle("Photo Information"); builder.setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.setView(wrapper); builder.create().show(); } @Override public void failure(RetrofitError error) { Log.i("testing", "could not retrieve legal/attribution info"); } }); }
From source file:com.secbro.qark.customintent.CreateCustomIntentActivity.java
private void createExtrasView() { LinearLayout topLayout = (LinearLayout) findViewById(R.id.extras_key_value_container); LinearLayout.LayoutParams llpTextView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpTextView.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); LinearLayout.LayoutParams llpEditText = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llpEditText.setMargins(10, 20, 10, 10); // llp.setMargins(left, top, right, bottom); //key//w w w .j av a2 s . com LinearLayout keyLinearLayout = new LinearLayout(this); keyLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView keyTextView = new TextView(this); keyTextView.setText(getResources().getString(R.string.intent_extras_key)); keyTextView.setLayoutParams(llpTextView); AutoCompleteTextView keyEditText = new AutoCompleteTextView(this); keyEditText.setLayoutParams(llpEditText); ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.intent_extras_array)); keyEditText.setAdapter(adapter3); keyEditText.setSelection(keyEditText.getText().length()); keyEditText.setTag("key_field"); keyLinearLayout.addView(keyTextView); keyLinearLayout.addView(keyEditText); //value LinearLayout valueLinearLayout = new LinearLayout(this); valueLinearLayout.setOrientation(LinearLayout.HORIZONTAL); TextView valueTextView = new TextView(this); valueTextView.setText(getResources().getString(R.string.intent_extras_value)); valueTextView.setLayoutParams(llpTextView); EditText valueEditText = new EditText(this); valueEditText.setTag("value_field"); valueEditText.setLayoutParams(llpEditText); valueLinearLayout.addView(valueTextView); valueLinearLayout.addView(valueEditText); topLayout.addView(keyLinearLayout); topLayout.addView(valueLinearLayout); }
From source file:eu.power_switch.gui.fragment.configure_scene.ConfigureSceneDialogPage1NameFragment.java
private void addReceiversToLayout() { String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString); try {/* w w w . j a va 2s . c o m*/ for (Room room : DatabaseHandler.getRooms(SmartphonePreferencesHandler.getCurrentApartmentId())) { LinearLayout roomLayout = new LinearLayout(getActivity()); roomLayout.setOrientation(LinearLayout.VERTICAL); roomLayout.setPadding(0, 8, 0, 8); linearLayout_selectableReceivers.addView(roomLayout); TextView roomName = new TextView(getActivity()); roomName.setText(room.getName()); roomName.setTextColor( ThemeHelper.getThemeAttrColor(getActivity(), android.R.attr.textColorPrimary)); roomLayout.addView(roomName); for (Receiver receiver : room.getReceivers()) { LinearLayout receiverLayout = new LinearLayout(getActivity()); receiverLayout.setOrientation(LinearLayout.HORIZONTAL); roomLayout.addView(receiverLayout); final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.simple_checkbox, receiverLayout, false); checkBox.setTag(R.string.room, room); checkBox.setTag(R.string.receiver, receiver); receiverLayout.addView(checkBox); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkValidity(); } }); receiverCheckboxList.add(checkBox); TextView textView_receiverName = new TextView(getActivity()); textView_receiverName.setText(receiver.getName()); receiverLayout.addView(textView_receiverName); receiverLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkBox.setChecked(!checkBox.isChecked()); } }); } } } catch (Exception e) { StatusMessageHandler.showErrorMessage(getActivity(), e); } }
From source file:com.sentaroh.android.Utilities.ContextMenu.CustomContextMenuFragment.java
private void initViewWidget() { if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "initViewWidget"); // CommonDialog.setDlgBoxSizeCompact(mDialog); LinearLayout dlg_ll = new LinearLayout(getActivity()); dlg_ll.setOrientation(LinearLayout.VERTICAL); TextView dlg_tv = new TextView(getActivity()); dlg_tv.setBackgroundColor(Color.WHITE); dlg_tv.setTextColor(Color.BLACK); // dlg_tv.setTextSize(32); dlg_tv.setGravity(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.CENTER_HORIZONTAL); ListView dlg_lv = new ListView(getActivity()); dlg_lv.setBackgroundColor(Color.WHITE); dlg_ll.addView(dlg_tv);// ww w. ja va 2 s. com dlg_ll.addView(dlg_lv); mDialog.setContentView(dlg_ll); if (mDialogTitle.length() != 0) { dlg_tv.setText(mDialogTitle); dlg_tv.setVisibility(TextView.VISIBLE); } else dlg_tv.setVisibility(TextView.GONE); dlg_lv.setAdapter(mMenuAdapter); dlg_lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> items, View view, int idx, long id) { CustomContextMenuItem item = (CustomContextMenuItem) mMenuAdapter.getItem(idx); if (item.menu_enabled) { if (idx < mClickHandler.size()) { mClickHandler.get(idx).onClick(item.text); } mFragment.dismiss(); } } }); dlg_lv.setScrollingCacheEnabled(false); dlg_lv.setScrollbarFadingEnabled(false); // int[] colors = {0, 0xFFFF0000, 0}; // red for the example // lv.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); dlg_lv.setDividerHeight(0); }