本文整理匯總了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;
}