2016-04-26 101 views
0

Register.xml文件,如何在機器人中使用微調器?

<RelativeLayout 
    android:id="@+id/spinner_relay" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_below="@id/fd_register_header" 
    android:layout_marginBottom="@dimen/dm_5dp" 
    android:layout_marginLeft="@dimen/dm_10dp" 
    android:layout_marginRight="@dimen/dm_10dp" 
    android:layout_marginTop="@dimen/dm_5dp" 
    android:background="@drawable/spinner_background" > 

    <TextView 
     android:id="@+id/fp_spinner" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:drawablePadding="@dimen/dm_10dp" 
     android:drawableRight="@drawable/icondown" 
     android:gravity="left|center" 
     android:padding="@dimen/dm_10dp" 
     android:text="Select city" 
     android:textColor="@color/white" 
     android:textSize="@dimen/dm_18sp" /> 
</RelativeLayout> 

如果我用這個代碼,

int pos = solo.getCurrentSpinners().get(0).getSelectedItemPosition(); 

得到錯誤,

不能解析符號getCurrentSpinner

+2

顯示您的完整代碼,請。 –

+0

在Solo類中沒有這樣的方法'getCurrentSpinners'。您可以使用isSpinnerTextSelected方法 – Pehlaj

回答

1

嘗試使用以下代碼與Spinners一起工作,這是什麼工作對我來說

solo.pressSpinnerItem(0, -5);  //selects the item in the spinner 

或者

solo.isSpinnerTextSelected(0,"Items") //checks whether the spinner item is selected