我在android中设计自定义微调器。此自定义微调器在大于3.0的版本上无法单击,并在填充微调器值后无法单击。请任何人可以找出下面的代码有什么问题然后我可以改变我的代码。
以下是自定义微调器图像
我的主要spinner.xml
<Spinner
android:id="@+id/projDetSpnrPhase"
style="@style/spinner_style"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginBottom="8dp"
android:clickable="true"
android:paddingBottom="10dp"
android:prompt="@string/phase" />
两种旋转器,一种用于版本&gt; 11,另一种用于版本&lt; 11
11
<style name="spinner_style" parent="fp_wc">
<item name="android:background">@drawable/spinner_selectors</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:popupBackground">#DFFFFFFF</item>
<item name="android:spinnerStyle">@android:style/Widget.Spinner.DropDown</item>
</style>
&LT; 11
<style name="spinner_style" parent="fp_wc">
<item name="android:background">@drawable/spinner_selectors</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_marginRight">10dp</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:popupBackground">#DFFFFFFF</item>
</style>
以下是微调器监听器。
spinnerPhase.setOnItemSelectedListener((OnItemSelectedListener)
new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
........
}
选择器的spinner_selectors.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Selected -->
<item
android:state_pressed="true"
android:drawable="@drawable/spinner_selector_selected" />
<!-- Pressed -->
<item
android:state_enabled="true"
android:drawable="@drawable/spinner_selectors_default" />
</selector>
spinner_selector_selected.xml用于微调框角落处的边框线和微调图像。
<?xml version="1.0" encoding="utf-8"?>
<item>
<layer-list>
<item>
<shape>
<stroke android:width="2dp" android:color="@color/gray" />
<corners android:radius="4dp" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="3dp"
android:top="3dp" />
<solid android:color="@color/pressed_color"/>
</shape>
</item>
<item>
<bitmap
android:gravity="bottom|right"
android:src="@drawable/spinner_ab_default_new_theme_bs" />
</item>
</layer-list>
答案 0 :(得分:0)
你的听众代码:
spinnerPhase.setOnItemSelectedListener((OnItemSelectedListener)
new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
........
}
将您的侦听器代码更改为:
spinnerPhase.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
............
}
然后检查并告诉我这个问题是否已解决?