Spinner无法使用水平列表视图



我是安卓系统的新手。我想提前特别感谢。问题是,我使用的是水平列表视图,并在水平列表视图适配器内部使用微调器。它显示在右边,但当我们点击微调器时,onItemSelected侦听器不会被调用。

下面的代码在适配器类中,该适配器类实现BaseAdapter

spinerConfigurableList=(Spinner) row.findViewById(R.id.spinerConfigurableList);
spinerConfigurableList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                   // spinerConfigurableList.setSelection(position);
                    configurableSelection=position;//Problem is here,this never invoke.
                }
                @Override
                public void onNothingSelected(AdapterView<?> parent) {
                }
            });
I am following this example https://github.com/MeetMe/Android-HorizontalListView
    Xml for adapter.
     <LinearLayout
    xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/llDrop"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"
            >
            <Spinner
                android:id="@+id/spinerConfigurableList"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:paddingLeft="0dp"
                android:paddingRight="0dp"
                android:prompt="@string/app_name"
                android:spinnerMode="dropdown"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:layout_margin="1dp"
                android:theme="@style/AppThemeForSpinner"
                android:textColor="@color/font_color_black_light"
                android:textSize="@dimen/font_size_level_two"
                ></Spinner>
        </LinearLayout>
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        // your code here
    }
    @Override
    public void onNothingSelected(AdapterView<?> parentView) {
        // your code here
    }
});

请改用此选项。

最新更新