2016-08-03 63 views
-1

我是新的android。我想特別感謝提前。 問題是,我正在使用水平列表視圖並在水平列表視圖適配器內使用微調框。它顯示正確,但當我們點擊微調,然後onItemSelected偵聽器不會被調用。微調不與水平lisview

下面的代碼是被implemened 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 
    } 
}); 

使用這個代替適配器類的內部。

+0

您好扎克Bullil,我使用相同,但有一點區別,您正在使用新的OnItemSelectedListener(){重寫方法},但我使用新的AdapterView.OnItemSelectedListener(){重寫方法}但是,我嘗試使用新的OnItemSelectedListener ),但沒有找到。當我們輸入ALT + ENTER導入類時,它已被改變爲像新的AdapterView.OnItemSelectedListener(),請解釋如何使用這個 –