2016-08-03 7 views
-1

私はアンドロイドを新しくしました。私は特別に事前に感謝したいと思います。 問題は、水平リストビューを使用していて、水平リストビューアダプタの内部でスピナーを使用しています。それは正しく表示されますが、スピナーをクリックすると、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> 
+0

コードを投稿してください。 – Jas

答えて

0
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 
    } 
}); 

代わりに使用しimplemenedれるアダプタクラスの内部にあります。

+0

こんにちはZach Bullil、私は同じですが、少し違いがあります、新しいOnItemSelectedListener()メソッドをオーバーライドしていますが、新しいAdapterView.OnItemSelectedListener(){overrideメソッド}を使用していますが、新しいOnItemSelectedListener( )が見つかりません。クラスをインポートするためにALT + ENTERを入力すると、新しいAdapterView.OnItemSelectedListener()のように変更されました。これを使用する方法を説明してください –

関連する問題