本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}