本文整理了Java中android.widget.Spinner.getItemAtPosition()
方法的一些代码示例,展示了Spinner.getItemAtPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spinner.getItemAtPosition()
方法的具体详情如下:
包路径:android.widget.Spinner
类名称:Spinner
方法名:getItemAtPosition
暂无
代码示例来源:origin: stackoverflow.com
mySpinner.setSelection(getIndex(mySpinner, myValue));
//private method of your class
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;
}
代码示例来源:origin: k9mail/k-9
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;
}
}
}
代码示例来源:origin: stackoverflow.com
private int getIndex(Spinner spinner, String myString){
int index = 0;
for (int i=0;i<spinner.getCount();i++){
if (spinner.getItemAtPosition(i).equals(myString)){
index = i;
}
}
return index;
}
代码示例来源:origin: ankidroid/Anki-Android
private int getSpinnerIndex(Spinner spinner, String myString){
int index = 0;
for (int i=0;i<spinner.getCount();i++){
if (spinner.getItemAtPosition(i).equals(myString)){
index = i;
}
}
return index;
}
}
代码示例来源:origin: fossasia/pslab-android
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selection = channelSelectSpinner2.getItemAtPosition(position).toString();
channel_one_list.clear();
for(int i = 0; i < channels.length; i++) {
if(!channels[i].equals(selection)) {
channel_one_list.add(channels[i]);
}
}
channel_one_adapter.notifyDataSetChanged();
}
代码示例来源:origin: fossasia/pslab-android
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selection = channelSelectSpinner1.getItemAtPosition(position).toString();
channel_two_list.clear();
for(int i = 0; i < channels.length; i++) {
if(!channels[i].equals(selection)) {
channel_two_list.add(channels[i]);
}
}
channel_two_adapter.notifyDataSetChanged();
}
代码示例来源:origin: chat-sdk/chat-sdk-android
protected 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;
}
代码示例来源:origin: fossasia/pslab-android
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
((OscilloscopeActivity) getActivity()).curveFittingChannel1 = spinnerChannelSelect1.getItemAtPosition(position).toString();
}
代码示例来源:origin: fossasia/pslab-android
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
((OscilloscopeActivity) getActivity()).curveFittingChannel2 = spinnerChannelSelect2.getItemAtPosition(position).toString();
}
代码示例来源:origin: fossasia/pslab-android
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
((OscilloscopeActivity) getActivity()).triggerChannel = spinnerTriggerChannelSelect.getItemAtPosition(position).toString();
}
代码示例来源:origin: stackoverflow.com
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setAdapter(new SimpleCursorAdapter(...));
for (int i = 0; i < spinner.getCount(); i++) {
Cursor value = (Cursor) spinner.getItemAtPosition(i);
long id = value.getLong(value.getColumnIndex("_id"));
if (id == rowid) {
spinner.setSelection(i);
}
}
代码示例来源:origin: advanced-android-book/samples
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// 選択時だけでなく、最初にも呼ばれる
String language = (String) languageSpinner.getItemAtPosition(position);
loadRepositories(language);
}
代码示例来源:origin: limboemu/limbo
@Override
public boolean onItemLongClick(AdapterView<?> arg0,
View arg1, int arg2, long arg3) {
spinnerConnection.setSelection(arg2);
selected = (ConnectionBean) spinnerConnection
.getItemAtPosition(arg2);
canvasStart();
return true;
}
代码示例来源:origin: com.albedinsky.android/ui
/**
* Delegate method for {@link android.widget.Spinner#getItemAtPosition(int)}.
*/
@Nullable
public Object getItemAtPosition(int position) {
return mSpinner != null ? mSpinner.getItemAtPosition(position) : null;
}
代码示例来源:origin: stackoverflow.com
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
String[] stringArray= new String[] { "A", "B", "C" };
// fill an arrayadapter and set it to the spinner
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, stringArray);
spinner.setAdapter(adapter);
String item = (String ) spinner.getItemAtPosition(0); // it will return your String so you can safely cast to it
代码示例来源:origin: stackoverflow.com
private void selectValue(Spinner spinner, Object value) {
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).equals(value)) {
spinner.setSelection(i);
break;
}
}
}
代码示例来源:origin: stackoverflow.com
private void selectSpinnerValue(Spinner spinner, String myString)
{
int index = 0;
for(int i = 0; i < spinner.getCount(); i++){
if(spinner.getItemAtPosition(i).toString().equals(myString)){
spinner.setSelection(i);
break;
}
}
}
代码示例来源:origin: FreedomZZQ/YouJoin-Android
public String GetAddress(){
return provinceSpinner.getItemAtPosition(provinceSpinner.getSelectedItemPosition()).toString()
+ citySpinner.getItemAtPosition(citySpinner.getSelectedItemPosition()).toString()
+ countySpinner.getItemAtPosition(countySpinner.getSelectedItemPosition()).toString();
}
代码示例来源:origin: stackoverflow.com
public int getPosition(Spinner your_spinner, String string_value){
int position = 0;
for (int i=0;i<your_spinner.getCount();i++){
if (your_spinner.getItemAtPosition(i).equals(string_value)){
position = i;
}
}
return position;
}
代码示例来源:origin: brarcher/video-transcoder
private void setSpinnerSelection(Spinner spinner, Object value)
{
for(int index = 0; index < spinner.getCount(); index++)
{
String item = spinner.getItemAtPosition(index).toString();
if(item.equals(value.toString()))
{
spinner.setSelection(index);
break;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!