2016-04-26 99 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