List of usage examples for android.widget LinearLayout setOrientation
public void setOrientation(@OrientationMode int orientation)
From source file:com.google.android.gcm.demo.ui.GroupsFragment.java
@Override public void refresh() { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> senders = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < senders.size(); i++) { Sender sender = senders.valueAt(i); if (sender.groups.size() > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderText = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderText.setText(getString(R.string.groups_sender_id, sender.senderId)); sendersList.addView(senderRow); for (DeviceGroup deviceGroup : sender.groups.values()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.group_grey600); label.setText(deviceGroup.notificationKeyName); label.setBackgroundResource(selectableBackgroundResource); label.setTag(R.id.tag_action, ACTION_OPEN_GROUP); label.setTag(R.id.tag_senderid, sender.senderId); label.setTag(R.id.tag_group, deviceGroup.notificationKeyName); label.setOnClickListener(this); button.setText(R.string.groups_delete); button.setTag(R.id.tag_action, ACTION_DELETE_GROUP); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_group, deviceGroup.notificationKeyName); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); }// w w w . j ava 2s . com } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.groups_no_groups_available)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.groups_list_wrapper); topicsView.removeAllViews(); topicsView.addView(sendersList); }
From source file:de.nico.asura.activities.WebView1.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_1_auth_fiFi)); layout.addView(edit_name);/*from w ww. j av a 2 s . c om*/ final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_1_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_1_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView1.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView1.this.finish(); } }).show(); }
From source file:de.nico.asura.activities.WebView2.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_2_auth_fiFi)); layout.addView(edit_name);/* w w w . j a va 2s . c o m*/ final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_2_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_2_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView2.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView2.this.finish(); } }).show(); }
From source file:de.nico.asura.activities.WebView3.java
private void checkLogin() { // Layout for Dialog final LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); final EditText edit_name = new EditText(this); edit_name.setHint(getString(R.string.menu_Web_3_auth_fiFi)); layout.addView(edit_name);/*from w w w . j a va2 s. co m*/ final EditText edit_pass = new EditText(this); edit_pass.setHint(getString(R.string.menu_Web_3_auth_seFi)); edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); layout.addView(edit_pass); final Builder builder = new Builder(this); builder.setTitle(getString(R.string.menu_Web_3_name)).setCancelable(false).setView(layout) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { firstField = edit_name.getText().toString(); secondField = edit_pass.getText().toString(); // Nothing? if (firstField.length() == 0 || secondField.length() == 0) { Utils.makeShortToast(WebView3.this, getString(R.string.wrong)); checkLogin(); return; } final Editor editor = prefs.edit(); editor.putString(sharedPrefFiFi, firstField); editor.putString(sharedPrefSeFi, secondField); editor.apply(); openWebView(); } }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { WebView3.this.finish(); } }).show(); }
From source file:com.normalexception.app.rx8club.dialog.MoveThreadDialog.java
/** * Constructor for method that is used to move a thread from one * forum to another // w ww . ja v a 2s. co m * @param ctx The source context/activity * @param securitytoken The security token for the session * @param src_thread The source thread * @param tTitle The new thread title * @param options The options from the move dialog */ public MoveThreadDialog(final Fragment ctx, final String securitytoken, final String src_thread, String tTitle, final Map<String, Integer> options) { builder = new AlertDialog.Builder(ctx.getActivity()); // Set up the input final TextView lbl_title = new TextView(ctx.getActivity()); final EditText title = new EditText(ctx.getActivity()); final TextView lbl_dest = new TextView(ctx.getActivity()); final Spinner destination = new Spinner(ctx.getActivity()); // Lets make sure the user didn't accidentally click this DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: newTitle = title.getText().toString(); String selectText = destination.getSelectedItem().toString(); selection = options.get(selectText); AsyncTask<Void, String, Void> updaterTask = new AsyncTask<Void, String, Void>() { @Override protected Void doInBackground(Void... params) { try { HtmlFormUtils.adminMoveThread(securitytoken, src_thread, newTitle, Integer.toString(selection)); } catch (Exception e) { Log.e(TAG, "Error Submitting Form For Move", e); } return null; } @Override protected void onPostExecute(Void result) { ctx.getFragmentManager().popBackStack(); CategoryFragment cFrag = (CategoryFragment) ((ThreadFragment) ctx).getParentCategory(); cFrag.refreshView(); } }; updaterTask.execute(); break; case DialogInterface.BUTTON_NEGATIVE: break; } } }; // Specify the type of input expected lbl_title.setText("Thread Title"); lbl_title.setTextColor(Color.WHITE); lbl_dest.setText("Desination"); lbl_dest.setTextColor(Color.WHITE); title.setInputType(InputType.TYPE_CLASS_TEXT); title.setText(tTitle); List<String> values = new ArrayList<String>(); values.addAll(options.keySet()); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(ctx.getActivity(), android.R.layout.simple_spinner_item, values); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); destination.setAdapter(dataAdapter); LinearLayout ll = new LinearLayout(ctx.getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(lbl_title); ll.addView(title); ll.addView(lbl_dest); ll.addView(destination); builder.setView(ll); builder.setTitle(R.string.dialogMoveThread).setPositiveButton(R.string.Move, dialogClickListener) .setNegativeButton(R.string.cancel, dialogClickListener); }
From source file:org.forgerock.openam.mobile.example.authentication.activities.authenticate.AuthenticateActivity.java
/** * Interrogates the previous Intent. If we were passed here with an authentication callback * to display to the screen, draw it here. * * @param savedInstanceState//from w w w . ja v a 2 s.c om */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent previous = getIntent(); final String authCallbackString = previous.getStringExtra(AppConstants.AUTH_CALLBACK); Authenticate auth = null; boolean errored = false; try { auth = AuthenticateFactory.createFromString(authCallbackString); } catch (JSONException e) { Log.e(TAG, "Unable to generate JSON representation of authentication stage.", e); errored = true; } if (errored || auth == null || auth.getCallbacks() == null) { finish(); //if we error here, we cannot continue with the activity } final LinearLayout newLayout = new LinearLayout(this); newLayout.setOrientation(LinearLayout.VERTICAL); newLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //for each callback returned to us, create a drawable callback from it, auth not null here final DrawableCallback[] dcs = new DrawableCallback[auth.getCallbacks().length]; //todo: clean this up, take it away from here. for (int i = 0; i < auth.getCallbacks().length; i++) { Callback cb = auth.getCallbacks()[i]; if (cb.getType().equals(PasswordCallback.TYPE)) { dcs[i] = new PasswordCallback(cb.getOutput()[0].getValue(), cb.getInput()[0].getName(), this); } else if (cb.getType().equals(NameCallback.TYPE)) { dcs[i] = new NameCallback(cb.getOutput()[0].getValue(), cb.getInput()[0].getName(), this); } } //put our new drawables on to the screen for (DrawableCallback dc : dcs) { newLayout.addView(dc.getDisplayElement()); } //add a submit button for the user to press Button submitButton = createSubmitButton(dcs, authCallbackString); newLayout.addView(submitButton); setContentView(newLayout); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from w ww .java 2 s . com*/ LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:com.javielinux.dialogs.CreateDefaultColumnsUserDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { userId = getArguments().getLong("user_id"); userEntity = new Entity("users", userId); CharSequence[] choices = new CharSequence[3]; choices[0] = getString(R.string.timeline); choices[1] = getString(R.string.mentions); choices[2] = getString(R.string.direct_messages); final boolean[] isChoices = new boolean[] { true, true, true }; LinearLayout llTitle = new LinearLayout(getActivity()); llTitle.setOrientation(LinearLayout.VERTICAL); final CheckBox boxInvite = new CheckBox(getActivity()); boxInvite.setText(R.string.follow_tweettopics); boxInvite.setChecked(true);/*ww w . j a va2s . c om*/ llTitle.addView(boxInvite); TextView txtTitle = new TextView(getActivity()); txtTitle.setText(R.string.create_columns); txtTitle.setTextSize(25); llTitle.addView(txtTitle); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setCustomTitle(llTitle); builder.setMultiChoiceItems(choices, isChoices, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { isChoices[whichButton] = isChecked; } }); builder.setCancelable(false); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // choices int count = DataFramework.getInstance().getEntityListCount("columns", "") + 1; if (isChoices[0]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_TIMELINE); Entity timeline = new Entity("columns"); timeline.setValue("description", type.getString("description")); timeline.setValue("type_id", type); timeline.setValue("position", count); timeline.setValue("user_id", userEntity.getId()); timeline.save(); count++; } if (isChoices[1]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_MENTIONS); Entity mentions = new Entity("columns"); mentions.setValue("description", type.getString("description")); mentions.setValue("type_id", type); mentions.setValue("position", count); mentions.setValue("user_id", userEntity.getId()); mentions.save(); count++; } if (isChoices[2]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_DIRECT_MESSAGES); Entity dms = new Entity("columns"); dms.setValue("description", type.getString("description")); dms.setValue("type_id", type); dms.setValue("position", count); dms.setValue("user_id", userEntity.getId()); dms.save(); } ((TweetTopicsActivity) getActivity()).refreshColumns(); // create friend if (boxInvite.isChecked()) { Utils.showMessage(getActivity(), getActivity().getString(R.string.thanks)); new Thread(new Runnable() { @Override public void run() { try { ConnectionManager.getInstance().getTwitter(userEntity.getId()) .createFriendship("tweettopics_app"); } catch (TwitterException e1) { e1.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } } }).start(); } } }); return builder.create(); }
From source file:com.google.android.gcm.demo.ui.TopicsFragment.java
@Override public void refresh() { float density = getActivity().getResources().getDisplayMetrics().density; SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders(); LinearLayout sendersList = new LinearLayout(getActivity()); sendersList.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < addressBook.size(); i++) { Sender sender = addressBook.valueAt(i); // Check if at least a topic is subscribed for this sender int subscribedTopics = 0; for (Boolean subscribed : sender.topics.values()) { if (subscribed) { subscribedTopics++;/* w w w . ja v a 2 s . c om*/ } } if (subscribedTopics > 0) { LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon); TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text); senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE); senderIcon.setImageResource(R.drawable.cloud_googblue); senderIcon.setPadding(0, 0, (int) (8 * density), 0); senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId)); sendersList.addView(senderRow); for (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) { if (topic.getValue()) { LinearLayout row = (LinearLayout) getActivity().getLayoutInflater() .inflate(R.layout.widget_icon_text_button_row, sendersList, false); ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon); TextView label = (TextView) row.findViewById(R.id.widget_itbr_text); Button button = (Button) row.findViewById(R.id.widget_itbr_button); icon.setImageResource(R.drawable.bigtop_updates_grey600); label.setText(topic.getKey()); button.setText(R.string.topics_unsubscribe); button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE); button.setTag(R.id.tag_senderid, sender.senderId); button.setTag(R.id.tag_topic, topic.getKey()); button.setOnClickListener(this); row.setPadding((int) (16 * density), 0, 0, 0); sendersList.addView(row); } } } } if (sendersList.getChildCount() == 0) { TextView noTokens = new TextView(getActivity()); noTokens.setText(getString(R.string.topics_no_topic_subscribed)); noTokens.setTypeface(null, Typeface.ITALIC); sendersList.addView(noTokens); } FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper); topicsView.removeAllViews(); topicsView.addView(sendersList); }
From source file:org.odk.collect.android.widgets.ArbitraryFileWidget.java
private void setUpLayout() { LinearLayout widgetLayout = new LinearLayout(getContext()); widgetLayout.setOrientation(LinearLayout.VERTICAL); chooseFileButton = getSimpleButton(getContext().getString(R.string.choose_file)); chooseFileButton.setEnabled(!getFormEntryPrompt().isReadOnly()); answerLayout = new LinearLayout(getContext()); answerLayout.setOrientation(LinearLayout.HORIZONTAL); answerLayout.setGravity(Gravity.CENTER); ImageView attachmentImg = new ImageView(getContext()); attachmentImg.setImageResource(R.drawable.ic_attachment); chosenFileNameTextView = getAnswerTextView(binaryName); chosenFileNameTextView.setGravity(Gravity.CENTER); answerLayout.addView(attachmentImg); answerLayout.addView(chosenFileNameTextView); answerLayout.setVisibility(binaryName == null ? GONE : VISIBLE); answerLayout.setOnClickListener(view -> openFile()); widgetLayout.addView(chooseFileButton); widgetLayout.addView(answerLayout);/*from ww w . j a v a 2 s.c o m*/ addAnswerView(widgetLayout); }