本文整理汇总了Java中android.widget.Spinner.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.getCount方法的具体用法?Java Spinner.getCount怎么用?Java Spinner.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Spinner
的用法示例。
在下文中一共展示了Spinner.getCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSpinnerOptionValue
import android.widget.Spinner; //导入方法依赖的package包/类
public static void setSpinnerOptionValue(Spinner spinner, Object value) {
for (int i = 0, count = spinner.getCount(); i < count; i++) {
SpinnerOption so = (SpinnerOption)spinner.getItemAtPosition(i);
if (so.value.equals(value)) {
spinner.setSelection(i, true);
return;
}
}
}
示例2: getSpinnerIndex
import android.widget.Spinner; //导入方法依赖的package包/类
/**
* Taken from Stack Overflow - https://stackoverflow.com/a/14640612/6052295
* Gets the index of a string inside a spinner
*
* @param spinner the spinner to check
* @param myString the item to search for in the spinner
* @return the index of the item in the spinner, default returns 0 if not found
*/
private int getSpinnerIndex(Spinner spinner, String myString) {
int index = 0;
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) {
index = i;
break;
}
}
return index;
}
示例3: categoryButtonListener
import android.widget.Spinner; //导入方法依赖的package包/类
public void categoryButtonListener(View v) {
Spinner categorySpinner = (Spinner) findViewById(R.id.category_spinner);
TextView categoryValidation = (TextView) findViewById(R.id.category_validation);
if (categorySpinner.getSelectedItemPosition() == categorySpinner.getCount()) {
categoryValidation.setVisibility(View.VISIBLE);
} else {
categoryValidation.setVisibility(View.INVISIBLE);
int categoryId =
((Spinner) findViewById(R.id.category_spinner)).getSelectedItemPosition();
mCategory = Category.values()[categoryId];
nextPage();
}
}
示例4: getIndexFromSpinnerByValue
import android.widget.Spinner; //导入方法依赖的package包/类
public static int getIndexFromSpinnerByValue(Spinner spinner, String myString) {
int index = 0;
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)) {
index = i;
break;
}
}
return index;
}
示例5: getIndex
import android.widget.Spinner; //导入方法依赖的package包/类
private int getIndex(Spinner spinner, String myString)
{
int index = 0;
for (int i=0;i<spinner.getCount();i++){
if (spinner.getItemAtPosition(i).toString().equalsIgnoreCase(myString)){
index = i;
break;
}
}
return index;
}