Example usage for android.widget LinearLayout setOrientation

List of usage examples for android.widget LinearLayout setOrientation

Introduction

In this page you can find the example usage for android.widget LinearLayout setOrientation.

Prototype

public void setOrientation(@OrientationMode int orientation) 

Source Link

Document

Should the layout be a column or a row.

Usage

From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java

public void verifyAccount() {
    final AlertDialog builder = new AlertDialog.Builder(this, R.style.InvitationDialog)
            .setPositiveButton("Done", null).setNegativeButton("Cancel", null).create();

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText emailBox = new EditText(this);
    emailBox.setTextColor(getResources().getColor(R.color.icons));
    emailBox.setHintTextColor(getResources().getColor(R.color.icons));
    emailBox.setHint("Email");
    layout.addView(emailBox);//  www. ja v  a  2 s.c om

    final EditText codeBox = new EditText(this);
    codeBox.setTextColor(getResources().getColor(R.color.icons));
    codeBox.setHintTextColor(getResources().getColor(R.color.icons));
    codeBox.setHint("Code");
    layout.addView(codeBox);

    builder.setView(layout);

    //      final EditText etNickName = new EditText(this);
    //      etNickName.setTextColor(Color.parseColor("#FFFFFF"));
    //      builder.setView(etNickName);
    builder.setTitle("Verify registration");

    builder.setMessage("Enter emailId and code to activate account");

    builder.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            final Button btnAccept = builder.getButton(AlertDialog.BUTTON_POSITIVE);
            btnAccept.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (emailBox.getText().toString().isEmpty() && codeBox.getText().toString().isEmpty()) {
                        Toast.makeText(getApplicationContext(), "Fields cannot be empty", Toast.LENGTH_SHORT)
                                .show();
                    } else {
                        verifyApi(emailBox.getText().toString(), codeBox.getText().toString());
                        builder.dismiss();
                    }
                }
            });

            final Button btnDecline = builder.getButton(DialogInterface.BUTTON_NEGATIVE);
            btnDecline.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    builder.dismiss();
                }
            });
        }
    });

    builder.show();

}

From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java

/**
 * Creates a TabBar in case action bar is not present as well as other UI Elements
 *//*from w  w w  .j  a  v  a2s  . c  om*/
private void initUI() {
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.LinearLayoutForSpareMenu);
        createSpareMenu(linearLayout);
    }

    mEditorLayout = (LinearLayout) findViewById(R.id.LinearLayoutInScrollView);

    LinearLayout mToolsLayout = (LinearLayout) findViewById(R.id.LinearLayoutForButtons);

    LayoutParams pars = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);

    Button swapButton = new Button(this);
    swapButton.setText(gtxt(R.string.multimedia_editor_activity_swap_button));
    mToolsLayout.addView(swapButton, pars);
    swapButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            swap();
        }
    });

    LinearLayout mButtonsLayout = new LinearLayout(this);
    mButtonsLayout.setOrientation(LinearLayout.HORIZONTAL);
    mToolsLayout.addView(mButtonsLayout, pars);

    pars = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);

    // DEPRECATED< BUT USED IN THE PROJECT.
    mModelButton = new Button(this);
    mModelButton.setOnClickListener(new OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_MODEL_SELECT);
        }
    });
    mButtonsLayout.addView(mModelButton, pars);

    mDeckButton = new Button(this);
    mDeckButton.setOnClickListener(new OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_DECK_SELECT);
        }
    });
    mButtonsLayout.addView(mDeckButton, pars);
}

From source file:com.sft.blackcatapp.SearchCoachActivity.java

private void showOpenCityPopupWindow(View parent) {
    if (openCityPopupWindow == null) {
        LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null);
        popWindowLayout.removeAllViews();
        // LinearLayout popWindowLayout = new LinearLayout(mContext);
        popWindowLayout.setOrientation(LinearLayout.VERTICAL);
        ListView OpenCityListView = new ListView(mContext);
        OpenCityListView.setDividerHeight(0);
        OpenCityListView.setCacheColorHint(android.R.color.transparent);
        OpenCityListView.setOnItemClickListener(new OnItemClickListener() {

            @Override/*from www  .j av  a  2s. c  o m*/
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                OpenCityVO selectCity = openCityList.get(position);
                System.out.println(selectCity.getName());
                cityname = selectCity.getName().replace("", "");
                licensetype = "";
                coachname = "";
                ordertype = "0";
                index = 1;
                obtainCaoch();
                openCityPopupWindow.dismiss();
                openCityPopupWindow = null;
            }
        });
        LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        popWindowLayout.addView(OpenCityListView, param);
        OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList);
        OpenCityListView.setAdapter(openCityAdapter);

        openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT);
    }
    openCityPopupWindow.setFocusable(true);
    openCityPopupWindow.setOutsideTouchable(true);
    // Back???
    openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable());

    openCityPopupWindow.showAsDropDown(parent);
}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

private AlertDialog.Builder generateCustomDialog(EditText nameInputET) {
    AlertDialog.Builder newFlowDialog = new AlertDialog.Builder(TheHubActivity.this);

    //Sets up Layout Parameters
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    params.setMarginStart(42);//w  w  w . j  a va 2s.  c  om
    params.setMarginEnd(50);

    AppUtils.setNameInputFilters(nameInputET);

    //Adds the ET and params to the layout of the dialog box
    layout.addView(nameInputET, params);

    newFlowDialog.setTitle("Name your new Flow.");

    newFlowDialog.setView(layout);

    return newFlowDialog;
}

From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);/*  w  w w .j a  v a 2  s  .co m*/
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());

    if (position == 1) {
        icon.setImageResource(icoColor1);
    } else {
        icon.setImageResource(selectedIcoColor);
    }

    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(icon, defaultTabLayoutParams);
    linearLayout.addView(tab, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:fr.cph.chicago.core.activity.BikeStationActivity.java

private void drawData() {
    final Context context = getApplicationContext();

    final LinearLayout availableLayout = new LinearLayout(context);
    final LinearLayout availableBikes = new LinearLayout(context);
    final LinearLayout availableDocks = new LinearLayout(context);

    final TextView availableBike = new TextView(context);
    final TextView availableDock = new TextView(context);
    final TextView amountBike = new TextView(context);
    final TextView amountDock = new TextView(context);

    container.removeAllViews();/*from   www.ja v  a  2  s . c o m*/
    container.setOrientation(LinearLayout.HORIZONTAL);
    availableLayout.setOrientation(LinearLayout.VERTICAL);
    availableBikes.setOrientation(LinearLayout.HORIZONTAL);
    availableBike.setText(bikeAvailableBikes);
    availableBike.setTextColor(grey_5);
    availableBikes.addView(availableBike);
    amountBike.setText(String.valueOf(bikeStation.getAvailableBikes()));
    if (bikeStation.getAvailableBikes() == 0) {
        amountBike.setTextColor(red);
    } else {
        amountBike.setTextColor(green);
    }
    availableBikes.addView(amountBike);
    availableLayout.addView(availableBikes);
    availableDocks.setOrientation(LinearLayout.HORIZONTAL);
    availableDock.setText(bikeAvailableDocks);
    availableDock.setTextColor(grey_5);
    availableDocks.addView(availableDock);
    amountDock.setText(String.valueOf(bikeStation.getAvailableDocks()));
    if (bikeStation.getAvailableDocks() == 0) {
        amountDock.setTextColor(red);
    } else {
        amountDock.setTextColor(green);
    }
    availableDocks.addView(amountDock);
    availableLayout.addView(availableDocks);
    container.addView(availableLayout);
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * @return/*from   w  ww .  j ava 2s  .c om*/
 */
private LinearLayout createInnerContainer() {
    LinearLayout innerContainer = new LinearLayout(this);
    innerContainer.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    innerContainer.setOrientation(LinearLayout.VERTICAL);
    innerContainer.setPadding(5, 0, 5, 5);
    return innerContainer;
}

From source file:net.mypapit.mobile.myrepeater.DisplayMap.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_map);
    overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_scale);

    hashMap = new HashMap<Marker, MapInfoObject>();

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }//  w w  w .  j a  va2  s . c  om

    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    if (map == null) {

        // Log.e("Map NULL", "MAP NULL");
        Toast.makeText(this, "Unable to display Map", Toast.LENGTH_SHORT).show();

    } else {

        LatLng latlng = (LatLng) getIntent().getExtras().get("LatLong");

        Repeater xlocation = new Repeater("", new Double[] { latlng.latitude, latlng.longitude });

        rl = RepeaterListActivity.loadData(R.raw.repeaterdata5, this);
        xlocation.calcDistanceAll(rl);
        rl.sort();

        map.setMyLocationEnabled(true);
        map.setOnInfoWindowClickListener(this);
        map.getUiSettings().setZoomControlsEnabled(true);

        AdView mAdView = (AdView) findViewById(R.id.adViewMap);
        mAdView.loadAd(new AdRequest.Builder().build());

        // counter i, for mapping marker with integer
        int i = 0;

        for (Repeater repeater : rl) {

            MarkerOptions marking = new MarkerOptions();
            marking.position(new LatLng(repeater.getLatitude(), repeater.getLongitude()));
            marking.title(repeater.getCallsign() + " - " + repeater.getDownlink() + "MHz (" + repeater.getClub()
                    + ")");

            marking.snippet("Tone: " + repeater.getTone() + " Shift: " + repeater.getShift());

            RepeaterMapInfo rmi = new RepeaterMapInfo(repeater);
            rmi.setIndex(i);

            hashMap.put(map.addMarker(marking), rmi);

            i++;

        }

        // Marker RKG = map.addMarker(new MarkerOptions().position(new
        // LatLng(6.1,100.3)).title("9M4RKG"));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 10));
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

        cache = this.getSharedPreferences(CACHE_PREFS, 0);

        Date cachedate = new Date(cache.getLong(CACHE_TIME, new Date(20000).getTime()));

        long secs = (new Date().getTime() - cachedate.getTime()) / 1000;
        long hours = secs / 3600L;
        secs = secs % 3600L;
        long mins = secs / 60L;

        if (mins < 5) {
            String jsoncache = cache.getString(CACHE_JSON, "none");
            if (jsoncache.compareToIgnoreCase("none") == 0) {
                new GetUserInfo(latlng, this).execute();

            } else {

                loadfromCache(jsoncache);
                // Toast.makeText(this, "Loaded from cache: " + mins +
                // " mins", Toast.LENGTH_SHORT).show();
            }

        } else {

            new GetUserInfo(latlng, this).execute();

        }

        map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

            @Override
            public View getInfoWindow(Marker marker) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                Context context = getApplicationContext(); // or
                // getActivity(),
                // YourActivity.this,
                // etc.

                LinearLayout info = new LinearLayout(context);
                info.setOrientation(LinearLayout.VERTICAL);

                TextView title = new TextView(context);
                title.setTextColor(Color.BLACK);
                title.setGravity(Gravity.CENTER);
                title.setTypeface(null, Typeface.BOLD);
                title.setText(marker.getTitle());

                TextView snippet = new TextView(context);
                snippet.setTextColor(Color.GRAY);
                snippet.setText(marker.getSnippet());

                info.addView(title);
                info.addView(snippet);

                return info;
            }
        });

    }

}

From source file:com.actionbarsherlock.internal.widget.IcsListPopupWindow.java

private int buildDropDown() {
    ViewGroup dropDownView;/*from   w w w.j a  va 2 s .c om*/
    int otherHeights = 0;

    if (mDropDownList == null) {
        Context context = mContext;

        mDropDownList = new DropDownListView(context, !mModal);
        if (mDropDownListHighlight != null) {
            mDropDownList.setSelector(mDropDownListHighlight);
        }
        mDropDownList.setAdapter(mAdapter);
        mDropDownList.setOnItemClickListener(mItemClickListener);
        mDropDownList.setFocusable(true);
        mDropDownList.setFocusableInTouchMode(true);
        mDropDownList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                if (position != -1) {
                    DropDownListView dropDownList = mDropDownList;

                    if (dropDownList != null) {
                        dropDownList.mListSelectionHidden = false;
                    }
                }
            }

            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        mDropDownList.setOnScrollListener(mScrollListener);

        if (mItemSelectedListener != null) {
            mDropDownList.setOnItemSelectedListener(mItemSelectedListener);
        }

        dropDownView = mDropDownList;

        View hintView = mPromptView;
        if (hintView != null) {
            // if an hint has been specified, we accomodate more space for it and
            // add a text view in the drop down menu, at the bottom of the list
            LinearLayout hintContainer = new LinearLayout(context);
            hintContainer.setOrientation(LinearLayout.VERTICAL);

            LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, 0, 1.0f);

            switch (mPromptPosition) {
            case POSITION_PROMPT_BELOW:
                hintContainer.addView(dropDownView, hintParams);
                hintContainer.addView(hintView);
                break;

            case POSITION_PROMPT_ABOVE:
                hintContainer.addView(hintView);
                hintContainer.addView(dropDownView, hintParams);
                break;

            default:
                break;
            }

            // measure the hint's height to find how much more vertical space
            // we need to add to the drop down's height
            int widthSpec = MeasureSpec.makeMeasureSpec(mDropDownWidth, MeasureSpec.AT_MOST);
            int heightSpec = MeasureSpec.UNSPECIFIED;
            hintView.measure(widthSpec, heightSpec);

            hintParams = (LinearLayout.LayoutParams) hintView.getLayoutParams();
            otherHeights = hintView.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;

            dropDownView = hintContainer;
        }

        mPopup.setContentView(dropDownView);
    } else {
        dropDownView = (ViewGroup) mPopup.getContentView();
        final View view = mPromptView;
        if (view != null) {
            LinearLayout.LayoutParams hintParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            otherHeights = view.getMeasuredHeight() + hintParams.topMargin + hintParams.bottomMargin;
        }
    }

    // getMaxAvailableHeight() subtracts the padding, so we put it back
    // to get the available height for the whole window
    int padding = 0;
    Drawable background = mPopup.getBackground();
    if (background != null) {
        background.getPadding(mTempRect);
        padding = mTempRect.top + mTempRect.bottom;

        // If we don't have an explicit vertical offset, determine one from the window
        // background so that content will line up.
        if (!mDropDownVerticalOffsetSet) {
            mDropDownVerticalOffset = -mTempRect.top;
        }
    }

    // Max height available on the screen for a popup.
    boolean ignoreBottomDecorations = mPopup.getInputMethodMode() == PopupWindow.INPUT_METHOD_NOT_NEEDED;
    final int maxHeight = /*mPopup.*/getMaxAvailableHeight(mDropDownAnchorView, mDropDownVerticalOffset,
            ignoreBottomDecorations);

    if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
        return maxHeight + padding;
    }

    final int listContent = /*mDropDownList.*/measureHeightOfChildren(MeasureSpec.UNSPECIFIED, 0,
            -1/*ListView.NO_POSITION*/, maxHeight - otherHeights, -1);
    // add padding only if the list has items in it, that way we don't show
    // the popup if it is not needed
    if (listContent > 0)
        otherHeights += padding;

    return listContent + otherHeights;
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

public DragItemRecyclerView addColumnList(final DragItemAdapter adapter, final View header,
        boolean hasFixedItemSize, int color, Drawable drawable) {
    final DragItemRecyclerView recyclerView = new DragItemRecyclerView(getContext());
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setDragItem(mDragItem);

    if (drawable != null) {
        if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            recyclerView.setBackgroundDrawable(drawable);
            GradientDrawable gd = (GradientDrawable) recyclerView.getBackground().getCurrent();
            gd.setColor(getResources().getColor(R.color.white));
            gd.setStroke(2, getResources().getColor(R.color.grey), 0, 0);
        } else {//from ww w .ja  v a2 s.co  m
            recyclerView.setBackground(drawable);
        }
    }
    if (color > 0) {
        mColumnLayout.setBackgroundColor(color);
    }
    //settings for ToH rules
    recyclerView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
    linearLayoutManager.setReverseLayout(true);
    recyclerView.setCanNotDragBelowTopItem(mCanNotDragBelowTopItem);
    recyclerView.setCanNotDropBelowTopItem(mCanNotDropBelowTopItem);
    recyclerView.setDragItemCallback(new DragItemRecyclerView.DragItemCallback() {
        @Override
        public boolean canDragItemAtPosition(int dragPosition) {
            return true;
        }

        @Override
        public boolean canDropItemAtPosition(int dropPosition) {
            if (dropPosition == adapter.getItemCount() - 1) {
                // Log.d("TAG", "TRUE");
                return true;
            }
            return false;
        }
    });
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setHasFixedSize(hasFixedItemSize);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setDragItemListener(new DragItemRecyclerView.DragItemListener() {
        @Override
        public void onDragStarted(int itemPosition, float x, float y) {
            mDragStartColumn = getColumnOfList(recyclerView);
            mDragStartRow = itemPosition;
            mCurrentRecyclerView = recyclerView;
            mDragItem.setOffset(((View) mCurrentRecyclerView.getParent()).getX(), mCurrentRecyclerView.getY());
            if (mBoardListener != null) {
                mBoardListener.onItemDragStarted(mDragStartColumn, mDragStartRow);
            }
            invalidate();
        }

        @Override
        public void onDragging(int itemPosition, float x, float y) {
        }

        @Override
        public void onDragEnded(int newItemPosition) {
            if (mBoardListener != null) {
                mBoardListener.onItemDragEnded(mDragStartColumn, mDragStartRow, getColumnOfList(recyclerView),
                        newItemPosition);
            }
        }
    });

    recyclerView.setAdapter(adapter);
    recyclerView.setDragEnabled(mDragEnabled);
    adapter.setDragStartedListener(new DragItemAdapter.DragStartCallback() {
        @Override
        public boolean startDrag(View itemView, long itemId) {
            return recyclerView.startDrag(itemView, itemId, getListTouchX(recyclerView),
                    getListTouchY(recyclerView));
        }

        @Override
        public boolean isDragging() {
            return recyclerView.isDragging();
        }
    });

    LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(mColumnWidth, LayoutParams.MATCH_PARENT));
    if (header != null) {
        layout.addView(header);
        mHeaders.put(mLists.size(), header);
    }
    layout.addView(recyclerView);

    mLists.add(recyclerView);
    mColumnLayout.addView(layout);
    return recyclerView;
}