當前位置: 首頁>>代碼示例>>Java>>正文


Java NumberPicker.setLayoutParams方法代碼示例

本文整理匯總了Java中android.widget.NumberPicker.setLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberPicker.setLayoutParams方法的具體用法?Java NumberPicker.setLayoutParams怎麽用?Java NumberPicker.setLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.NumberPicker的用法示例。


在下文中一共展示了NumberPicker.setLayoutParams方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
/**
 *
 * @return dialog view with picker inside
 */
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    numPicker= new NumberPicker(getContext());
    numPicker.setLayoutParams(layoutParams);
    numPicker.setMinValue(minValue);
    numPicker.setMaxValue(maxValue);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(numPicker);

    return dialogView;
}
 
開發者ID:leonardarnold,項目名稱:NumberPickerPreference,代碼行數:21,代碼來源:NumberPickerPreference.java

示例2: onPrepareDialogBuilder

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected void onPrepareDialogBuilder(final Builder builder) {
    super.onPrepareDialogBuilder(builder);
    mNumberPicker = new NumberPicker(getContext());
    mNumberPicker.setMinValue(mMinValue);
    mNumberPicker.setMaxValue(mMaxValue);
    mNumberPicker.setValue(mSelectedValue);
    mNumberPicker.setWrapSelectorWheel(mWrapSelectorWheel);
    mNumberPicker.setLayoutParams(new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    for (int i = 0; i < mNumberPicker.getChildCount(); i++) {
        View v = mNumberPicker.getChildAt(i);
        if (v instanceof EditText) {
            v.setOnKeyListener(new KeyListener());
        }
    }
    final LinearLayout linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(mNumberPicker);

    builder.setView(linearLayout);
}
 
開發者ID:JackWink,項目名稱:tweakable,代碼行數:26,代碼來源:NumberPickerPreference.java

示例3: createNumberPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
public NumberPicker createNumberPicker(final String[] names, final int level) {
    NumberPicker numberPicker = new NumberPicker(getContext());
    numberPicker.setTag(level);

    LinearLayout.LayoutParams params = new LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.leftMargin = 5;
    params.rightMargin = 5;

    numberPicker.setLayoutParams(params);
    numberPicker.setWrapSelectorWheel(true);
    numberPicker.setOnValueChangedListener(this);
    numberPicker.setMinValue(0);
    numberPicker.setMaxValue(names.length - 1);
    numberPicker.setDisplayedValues(names);

    return numberPicker;
}
 
開發者ID:LyndonChin,項目名稱:AndroidAreaPicker,代碼行數:19,代碼來源:AreaPicker.java

示例4: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.weight = 1;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    beforeTV = new TextView(getContext());
    beforeTV.setText(beforeText);
    beforeTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18.0f);
    beforeTV.setPadding(0,20,0,0);
    beforeTV.setGravity(Gravity.END);
    beforeTV.setTypeface(Typeface.DEFAULT_BOLD);

    afterTV = new TextView(getContext());
    afterTV.setText(afterText);
    afterTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18.0f);
    afterTV.setPadding(0,0,0,20);
    afterTV.setGravity(Gravity.START);
    afterTV.setTypeface(Typeface.DEFAULT_BOLD);

    layoutParams.weight = 5;
    beforeTV.setLayoutParams(layoutParams);
    afterTV.setLayoutParams(layoutParams);

    LinearLayout dialogView = new LinearLayout(getContext());
    dialogView.setOrientation(LinearLayout.VERTICAL);
    dialogView.addView(beforeTV);
    dialogView.addView(picker);
    dialogView.addView(afterTV);

    return dialogView;
}
 
開發者ID:abhijitvalluri,項目名稱:fitnotifications,代碼行數:36,代碼來源:NumberPickerPreference.java

示例5: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);

    return dialogView;
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:14,代碼來源:NumberPickerPreference.java

示例6: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);
    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);
    return dialogView;
}
 
開發者ID:LCA311,項目名稱:leoapp-sources,代碼行數:12,代碼來源:NumberPickerPreference.java

示例7: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);

    return dialogView;
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-werewolf,代碼行數:15,代碼來源:NumberPickerPreference.java

示例8: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);

    return dialogView;
}
 
開發者ID:lidox,項目名稱:reaction-test,代碼行數:15,代碼來源:NumberPickerPreference.java

示例9: onCreateDialogView

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
protected View onCreateDialogView() {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;

    picker = new NumberPicker(getContext());
    picker.setLayoutParams(layoutParams);

    FrameLayout dialogView = new FrameLayout(getContext());
    dialogView.addView(picker);

    return dialogView;
}
 
開發者ID:dhasenfratz,項目名稱:hRouting_Android,代碼行數:16,代碼來源:NumberPickerPreference.java

示例10: resizeNumberPicker

import android.widget.NumberPicker; //導入方法依賴的package包/類
private void resizeNumberPicker(NumberPicker np){
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    np.setLayoutParams(params);
}
 
開發者ID:yun2win,項目名稱:yun2win-sdk-android,代碼行數:5,代碼來源:ChooseDateDialog.java

示例11: onPreferenceClick

import android.widget.NumberPicker; //導入方法依賴的package包/類
@Override
public boolean onPreferenceClick(final Preference preference) {
    int maxValue;

    switch (preference.getKey()) {
        case "connection_timeout":
            maxValue = 180;
            break;
        case "one_request_limit":
            maxValue = 15000;
            break;
        case "notify_fire_duration":
            maxValue = 10080;
            break;
        case "carbon_limit":
            maxValue = 5000;
            break;
        default:
            maxValue = 42;
            break;
    }

    int value = preference.getSharedPreferences().getInt(preference.getKey(), 1);

    final NumberPicker picker = new NumberPicker(getContext());
    picker.setMinValue(1);
    picker.setMaxValue(maxValue);
    picker.setValue(value);
    picker.setWrapSelectorWheel(false);
    picker.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    final LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(picker);

    new AlertDialog.Builder(getContext())
            .setTitle(preference.getTitle())
            .setView(linearLayout)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    picker.clearFocus();
                    int newValue = picker.getValue();
                    SharedPreferences.Editor editor = preference.getSharedPreferences().edit();
                    editor.putInt(preference.getKey(), newValue);
                    editor.apply();
                }
            })
            .setNegativeButton(android.R.string.cancel, null)
            .show();

    return true;
}
 
開發者ID:vit1-irk,項目名稱:idec-mobile,代碼行數:55,代碼來源:SettingsFragment.java


注:本文中的android.widget.NumberPicker.setLayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。