本文整理匯總了Java中android.support.v7.widget.AppCompatSpinner類的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatSpinner類的具體用法?Java AppCompatSpinner怎麽用?Java AppCompatSpinner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AppCompatSpinner類屬於android.support.v7.widget包,在下文中一共展示了AppCompatSpinner類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_payment_information, container, false);
AppCompatSpinner cardType = (AppCompatSpinner) view.findViewById(R.id.card_type);
TextInputEditText cardNumber = (TextInputEditText) view.findViewById(R.id.card_number);
TextInputEditText expirationDate = (TextInputEditText) view.findViewById(R.id.expiration_date);
TextInputEditText securityCode = (TextInputEditText) view.findViewById(R.id.security_code);
TextView cardTypeError = (TextView) view.findViewById(R.id.card_type_error);
view.findViewById(R.id.submit).setOnClickListener(this);
validator =
new PaymentInformationFormValidator(cardType, cardNumber, expirationDate, securityCode, cardTypeError);
return view;
}
示例2: onCreateView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_address, container, false);
TextInputEditText address = (TextInputEditText) view.findViewById(R.id.address);
TextInputEditText city = (TextInputEditText) view.findViewById(R.id.city);
AppCompatSpinner state = (AppCompatSpinner) view.findViewById(R.id.state);
TextView stateError = (TextView) view.findViewById(R.id.state_error);
TextInputEditText zipCode = (TextInputEditText) view.findViewById(R.id.zip_code);
AppCompatSpinner country = (AppCompatSpinner) view.findViewById(R.id.country);
TextView countryError = (TextView) view.findViewById(R.id.country_error);
view.findViewById(R.id.submit).setOnClickListener(this);
validator = new AddressFormValidator(address, city, state, zipCode, country, stateError, countryError);
return view;
}
示例3: onCreate
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Edit Profile");
mFirstName = (EditText) findViewById(R.id.first_name);
mLastName = (EditText) findViewById(R.id.last_name);
mSex = (AppCompatSpinner) findViewById(R.id.sex);
mUnit = (AppCompatSpinner) findViewById(R.id.unit);
mAge = (EditText) findViewById(R.id.age);
user = (User) getIntent().getSerializableExtra(USER);
client = new OkHttpClient();
}
示例4: init
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
private void init() {
setOrientation(HORIZONTAL);
spinner = new AppCompatSpinner(getContext(), null,
R.attr.toolbarSpinnerStyle);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int dropDownVerticalOffset = getResources().getDimensionPixelSize(
R.dimen.popup_dropdown_v_offset_ge_21);
spinner.setDropDownVerticalOffset(dropDownVerticalOffset);
}
addView(spinner, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
}
示例5: onCreate
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_misc);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_back);
toolbar.setTitle(null);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
AppCompatSpinner spinner = (AppCompatSpinner) findViewById(R.id.toolbarSpinner);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item_spinner,
new String[]{"One", "Two", "Three", "Four", "Five", "Six"});
adapter.setDropDownViewResource(R.layout.list_item_spinner_dropdown);
spinner.setAdapter(adapter);
}
示例6: onCreate
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mSpinnerDelay = (AppCompatSpinner) findViewById(R.id.spinner_delay);
mSpinnerSlide = (AppCompatSpinner) findViewById(R.id.spinner_slide);
mSpinnerDelay.setAdapter(new ArrayAdapter<>(this, R.layout.spinner, mDelayGravities));
mSpinnerSlide.setAdapter(new ArrayAdapter<>(this, R.layout.spinner, mSlideGravities));
mSpinnerDelay.setSelection(1);
mSpinnerSlide.setSelection(1);
mSpinnerDelay.setOnItemSelectedListener(this);
mSpinnerSlide.setOnItemSelectedListener(this);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(new Adapter());
startMaterialIn();
}
示例7: getSelectedGravity
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
private int getSelectedGravity(AppCompatSpinner spinner) {
int index = spinner.getSelectedItemPosition();
int gravity = Gravity.TOP;
switch (index) {
case 0:
gravity = Gravity.TOP;
break;
case 1:
gravity = Gravity.BOTTOM;
break;
case 2:
gravity = Gravity.LEFT;
break;
case 3:
gravity = Gravity.RIGHT;
break;
}
return gravity;
}
示例8: onCreateView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
// Allow super to try and create a view first
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
switch (name) {
case "EditText":
return new AppCompatEditText(this,attrs);
case "Spinner":
return new AppCompatSpinner(this,attrs);
case "CheckBox":
return new AppCompatCheckBox(this,attrs);
case "RadioButton":
return new AppCompatRadioButton(this,attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this,attrs);
}
}
return null;
}
示例9: onCreateView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
// Provide colorized/tinted widgets on non-Material devices
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
switch (name) {
case "EditText":
return new AppCompatEditText(this, attrs);
case "Spinner":
return new AppCompatSpinner(this, attrs);
case "CheckBox":
return new AppCompatCheckBox(this, attrs);
case "RadioButton":
return new AppCompatRadioButton(this, attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this, attrs);
}
}
return null;
}
示例10: onCreateView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
// Allow super to try and create a view first
final View result = super.onCreateView(name, context, attrs);
if (result != null) {
return result;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// If we're running pre-L, we need to 'inject' our tint aware Views in place of the
// standard framework versions
switch (name) {
case "EditText":
return new AppCompatEditText(this, attrs);
case "Spinner":
return new AppCompatSpinner(this, attrs);
case "CheckBox":
return new AppCompatCheckBox(this, attrs);
case "RadioButton":
return new AppCompatRadioButton(this, attrs);
case "CheckedTextView":
return new AppCompatCheckedTextView(this, attrs);
}
}
return null;
}
示例11: setupLanguageSelect
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
void setupLanguageSelect(final Context context, final View view) {
AppCompatSpinner spinner = (AppCompatSpinner) view.findViewById(R.id.languageSpinner);
List<String> selections = new ArrayList<>();
selections.add(getResources().getString(R.string.Finnish));
selections.add(getResources().getString(R.string.Swedish));
selections.add(getResources().getString(R.string.English));
ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getActivity(), R.layout.setting_spinner_item, selections);
adapter.setDropDownViewResource(R.layout.setting_spinner_dropdown_item);
spinner.setAdapter(adapter);
String languageSetting = AppPreferences.getLanguageCodeSetting(context);
switch (languageSetting) {
case AppPreferences.LANGUAGE_CODE_FI:
spinner.setSelection(0);
break;
case AppPreferences.LANGUAGE_CODE_SV:
spinner.setSelection(1);
break;
default: // "en"
spinner.setSelection(2);
break;
}
spinner.setOnItemSelectedListener(new LanguageSelectedListener(context));
}
示例12: ChoiceView
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
public ChoiceView(Context context, String titleText) {
super(context);
LayoutInflater.from(context).inflate(R.layout.view_choice, this);
((TextView) findViewById(R.id.txt_choice_title)).setText(titleText);
mSpinner = (AppCompatSpinner) findViewById(R.id.spinner_choice);
mCheckBox = (AppCompatCheckBox) findViewById(R.id.check_choice);
mEditText = (EditText) findViewById(R.id.edit_text_choice);
mCheckBoxes = (LinearLayout) findViewById(R.id.container_check_boxes);
mBottomSeparator = findViewById(R.id.separator_choice_bottom);
}
示例13: PaymentInformationFormValidator
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
public PaymentInformationFormValidator(AppCompatSpinner cardType, TextInputEditText cardNumber,
TextInputEditText expirationDate, TextInputEditText securityCode, TextView cardTypeError) {
this.cardNumber = cardNumber;
this.expirationDate = expirationDate;
this.securityCode = securityCode;
this.cardTypeError = cardTypeError;
add(new NotEqualsConstraint(cardType, "Card type", PROPERTY_CARD_TYPE));
add(new NotBlankConstraint(cardNumber, PROPERTY_CARD_NUMBER));
add(new NotBlankConstraint(expirationDate, PROPERTY_EXPIRATION_DATE));
add(new NotBlankConstraint(securityCode, PROPERTY_SECURITY_CODE));
}
示例14: AddressFormValidator
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
public AddressFormValidator(TextInputEditText address, TextInputEditText city, AppCompatSpinner state,
TextInputEditText zipCode, AppCompatSpinner country, TextView stateError, TextView countryError) {
this.address = address;
this.city = city;
this.zipCode = zipCode;
this.stateError = stateError;
this.countryError = countryError;
add(new NotBlankConstraint(address, PROPERTY_ADDRESS));
add(new NotBlankConstraint(city, PROPERTY_CITY));
add(new NotEqualsConstraint(state, "State", PROPERTY_STATE));
add(new NotBlankConstraint(zipCode, PROPERTY_ZIP_CODE));
add(new NotEqualsConstraint(country, "Country", PROPERTY_COUNTRY));
}
示例15: onCreate
import android.support.v7.widget.AppCompatSpinner; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mImage = (AppCompatImageView) findViewById(R.id.image);
mButton = (AppCompatButton) findViewById(R.id.button);
mSpinner = (AppCompatSpinner) findViewById(R.id.spinner);
setLightStatusBar(findViewById(R.id.activity_main));
mCurrentType = ANIM_FADE_SCALE;
setupButton();
setupSpinner();
instantiateAnimatedVectorDrawables();
}