Example usage for android.widget LinearLayout VERTICAL

List of usage examples for android.widget LinearLayout VERTICAL

Introduction

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

Prototype

int VERTICAL

To view the source code for android.widget LinearLayout VERTICAL.

Click Source Link

Usage

From source file:com.manning.androidhacks.hack004.preference.AboutDialog.java

@Override
protected View onCreateDialogView() {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView splashText = new TextView(mContext);
    String fmt = "Version %s<br />" + "<a href=\"http://manning.com/sessa\">MoreInfo</a>";
    try {//from   w w  w.  ja va 2  s . c  om
        String pkg = mContext.getPackageName();
        mVersionNumber = mContext.getPackageManager().getPackageInfo(pkg, 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    if (mVersionNumber != null) {
        String aboutMsg = String.format(fmt, mVersionNumber);
        splashText.setText(Html.fromHtml(aboutMsg));
        splashText.setMovementMethod(LinkMovementMethod.getInstance());
    }

    layout.addView(splashText);

    return layout;
}

From source file:org.musicmod.android.dialog.SleepTimerDialog.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    setContentView(new LinearLayout(this));

    DisplayMetrics dm = new DisplayMetrics();
    dm = getResources().getDisplayMetrics();

    action = getIntent().getAction();//from w w w.  j av a2s. c o m

    mSleepTimerDialog = new AlertDialog.Builder(this).create();
    mSleepTimerDialog.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mRemained = (int) MusicUtils.getSleepTimerRemained() / 1000 / 60;

    LinearLayout mContainer = new LinearLayout(this);
    mContainer.setOrientation(LinearLayout.VERTICAL);
    mContainer.setPadding((int) dm.density * 8, 0, (int) dm.density * 8, 0);
    mTimeView = new TextView(this);
    mContainer.addView(mTimeView);
    mSetTime = new SeekBar(this);
    mSetTime.setMax(120);
    mContainer.addView(mSetTime);

    if (mRemained > 0) {
        mSetTime.setProgress(mRemained);
    } else {
        mSetTime.setProgress(30);
    }

    mSetTime.setOnSeekBarChangeListener(this);

    mProgress = mSetTime.getProgress();
    mTimerTime = mProgress;
    if (mTimerTime >= 1) {
        mPrompt = SleepTimerDialog.this.getResources().getQuantityString(R.plurals.NNNminutes, mTimerTime,
                mTimerTime);
    } else {
        mPrompt = SleepTimerDialog.this.getResources().getString(R.string.disabled);
    }
    mTimeView.setText(mPrompt);

    if (INTENT_SLEEP_TIMER.equals(action)) {
        mSleepTimerDialog.setIcon(android.R.drawable.ic_dialog_info);
        mSleepTimerDialog.setTitle(R.string.set_time);
        mSleepTimerDialog.setView(mContainer);
        mSleepTimerDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.ok),
                new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        if (mTimerTime >= 1) {
                            long milliseconds = mTimerTime * 60 * 1000;
                            boolean gentle = new PreferencesEditor(getApplicationContext())
                                    .getBooleanPref(KEY_GENTLE_SLEEPTIMER, true);
                            MusicUtils.startSleepTimer(milliseconds, gentle);
                        } else {
                            MusicUtils.stopSleepTimer();
                        }
                        finish();
                    }
                });
        mSleepTimerDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
                new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        finish();
                    }
                });
        mSleepTimerDialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {

                finish();
            }
        });
    } else {
        Toast.makeText(this, R.string.error_bad_parameters, Toast.LENGTH_SHORT).show();
        finish();
    }
}

From source file:com.android.calculator2.Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout root = new FrameLayout(context);

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);//from w w  w  .j  a  va  2 s  . c o  m

    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.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_VIEW_CONTAINER_ID);

    View cv = inflateView(savedInstanceState);
    cv.setId(android.R.id.content);
    lframe.addView(cv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT));

    return root;
}

From source file:org.musicmod.android.dialog.EqualizerDialog.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    mPrefs = new PreferencesEditor(getApplicationContext());

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    mScrollView = new ScrollView(this);
    mScrollView.setVerticalScrollBarEnabled(false);

    setContentView(mScrollView);/*w ww  .  j  av a 2  s.  c  o m*/

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

    mScrollView.addView(mLinearLayout);

    DisplayMetrics dm = new DisplayMetrics();
    dm = getResources().getDisplayMetrics();

    getWindow().setLayout((int) (300 * dm.density), WindowManager.LayoutParams.WRAP_CONTENT);

}

From source file:com.mishiranu.dashchan.content.service.AudioPlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = new ContextThemeWrapper(this, Preferences.getThemeResource());
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    float density = ResourceUtils.obtainDensity(this);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    int padding = getResources().getDimensionPixelSize(R.dimen.dialog_padding_view);
    linearLayout.setPadding(padding, padding, padding, C.API_LOLLIPOP ? (int) (8f * density) : padding);
    textView = new TextView(context, null, android.R.attr.textAppearanceListItem);
    linearLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    textView.setPadding(0, 0, 0, 0);/*from  w  w  w  .  j a  v a 2  s.c o m*/
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setSingleLine(true);
    LinearLayout horizontal = new LinearLayout(context);
    horizontal.setOrientation(LinearLayout.HORIZONTAL);
    horizontal.setGravity(Gravity.CENTER_VERTICAL);
    horizontal.setPadding(0, (int) (16f * density), 0, 0);
    linearLayout.addView(horizontal, LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    seekBar = new SeekBar(context);
    horizontal.addView(seekBar, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    seekBar.setPadding((int) (8f * density), 0, (int) (16f * density), 0);
    seekBar.setOnSeekBarChangeListener(this);
    button = new ImageButton(context);
    horizontal.addView(button, (int) (48f * density), (int) (48f * density));
    button.setBackgroundResource(
            ResourceUtils.getResourceId(context, android.R.attr.listChoiceBackgroundIndicator, 0));
    setPlayState(false);
    button.setOnClickListener(this);
    alertDialog = new AlertDialog.Builder(context).setView(linearLayout).setOnCancelListener(this)
            .setPositiveButton(R.string.action_stop, this).show();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(AudioPlayerService.ACTION_TOGGLE);
    intentFilter.addAction(AudioPlayerService.ACTION_CANCEL);
    LocalBroadcastManager.getInstance(this).registerReceiver(audioPlayerReceiver, intentFilter);
    bindService(new Intent(this, AudioPlayerService.class), this, 0);
}

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:de.mkrtchyan.aospinstaller.DonationsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setId(1111111);/*from ww w.  j a va2  s  .c  o  m*/

    setContentView(layout);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    DonationsFragment donationsFragment;
    donationsFragment = DonationsFragment.newInstance(BuildConfig.DEBUG, GOOGLE_PLAY, GOOGLE_PUBKEY,
            GOOGLE_CATALOG, getResources().getStringArray(R.array.donation_google_catalog_values), FLATTR,
            FLATTR_PROJECT_URL, FLATTR_URL);

    ft.replace(layout.getId(), donationsFragment, "donationsFragment");
    ft.commit();
}

From source file:org.hedgewars.hedgeroid.LocalRoomActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // TODO find a better central location / way to set up the default scheme and weaponset
    Netplay netplay = Netplay.getAppInstance(getApplicationContext());
    stateManager = new LocalRoomStateManager(netplay.defaultScheme, netplay.defaultWeaponset);

    setContentView(R.layout.activity_localroom);
    startButton = (Button) findViewById(R.id.startGame);

    startButton.setOnClickListener(startButtonClickListener);

    // Set up a tabbed UI for medium and small screens
    tabHost = (TabHost) findViewById(android.R.id.tabhost);
    if (tabHost != null) {
        tabHost.setup();//from   ww  w .j  a  v  a  2  s . c  o  m
        tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL);

        tabHost.addTab(tabHost.newTabSpec("map")
                .setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_map, 0))
                .setContent(R.id.mapFragment));
        tabHost.addTab(tabHost.newTabSpec("settings")
                .setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_settings, 0))
                .setContent(R.id.settingsFragment));
        tabHost.addTab(tabHost.newTabSpec("teams")
                .setIndicator(UiUtils.createVerticalTabIndicator(tabHost, R.string.room_tab_teams, 0))
                .setContent(R.id.teamlistContainer));

        if (icicle != null) {
            tabHost.setCurrentTabByTag(icicle.getString("currentTab"));
        }
    }
}

From source file:com.viewpagerindicator.VerticalTabPageIndicator.java

@SuppressWarnings("deprecation")
public VerticalTabPageIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    setVerticalScrollBarEnabled(false);/*from  w  w w. j  a va  2s. co  m*/

    mInflater = LayoutInflater.from(context);

    mTabLayout = new LinearLayout(getContext()) {

        {
            setOrientation(LinearLayout.VERTICAL);
        }
    };
    addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.FILL_PARENT));
}

From source file:de.nico.asura.activities.AuthWebView1.java

private void checkLogin() {
    // Layout for Dialog
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText edit_name = new EditText(this);
    edit_name.setHint(getString(R.string.menu_AuthWeb_1_fiFi));
    layout.addView(edit_name);/*  w  w  w .  j  a v  a2 s .c  o m*/

    final EditText edit_pass = new EditText(this);
    edit_pass.setHint(getString(R.string.menu_AuthWeb_1_seFi));
    edit_pass.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    layout.addView(edit_pass);

    Builder builder = new Builder(this);
    builder.setTitle(getString(R.string.menu_AuthWeb_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(AuthWebView1.this, getString(R.string.wrong));
                        checkLogin();
                        return;

                    }

                    Editor editor = prefs.edit();
                    editor.putString("firstFirst", firstField);
                    editor.putString("firstSecond", secondField);
                    editor.commit();

                    openWebView();

                }

            }).setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    AuthWebView1.this.finish();

                }

            }).show();

}