0

工作,我有我選擇的項目在Android的可點擊列表視圖和連鎖反應是工作,但我改變我的風格的文件中添加這一行的按鈕連鎖反應工作漣漪效應不會在列表視圖

<style name="InflorTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
     //other things 
     <item name="colorControlHighlight">@color/ripple_material_dark</item> 
    </style> 

我添加了這一行後,連鎖效果在按鈕中起作用,但在listview中不起作用。

任何建議來解決我的問題?

這裏是我的stles文件:

<resources> 
    <style name="InflorTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <item name="windowNoTitle">true</item> 
     <item name="windowActionBar">false</item> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="colorControlNormal">@color/colorAccent</item> 
     <item name="colorControlHighlight">@color/ripple_material_dark</item> 
    </style> 
    <style name="InflorTheme" parent="InflorTheme.Base"> 
    </style> 
    <style name="InflorTheme.Splash" parent="android:Theme"> 
     <item name="android:windowTranslucentStatus">true</item> 
     <item name="android:windowBackground">@drawable/splash</item> 
     <item name="android:windowNoTitle">true</item> 
    </style> 
</resources> 

這裏是我的風格的V-21:

<resources> 
    <style name="InflorTheme" parent="InflorTheme.Base"> 
     <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
     <item name="android:windowContentTransitions">true</item> 
     <item name="android:windowAllowEnterTransitionOverlap">true</item> 
     <item name="android:windowAllowReturnTransitionOverlap">true</item> 
     <item name="android:windowSharedElementEnterTransition">@android:transition/move</item> 
     <item name="android:windowSharedElementExitTransition">@android:transition/move</item> 
    </style> 
</resources> 

這裏是我的列表視圖:

<Mvx.MvxListView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/listBoletins" 
      android:footerDividersEnabled="true" 
      android:headerDividersEnabled="true" 
      android:dividerHeight="1dp" 
      android:textFilterEnabled="false" 
      android:layout_weight="1" 
      android:background="?android:attr/selectableItemBackground" 
      local:MvxBind="ItemsSource Boletins; ItemClick BoletimClickCommand" 
      local:MvxItemTemplate="@layout/boletinsitem" /> 

回答

0

你爲什麼做出這樣的簡單事情太複雜了。你應該使用ListView或者MvxListView的「appcompat listview」intead,並且嘗試根據你的需求改變你的風格對此語句。

如果U對您的自定義listview有自己的限制,那麼您應該嘗試這樣。 MyView的是您的佈局視圖

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.your_layout); 

    View myView = findViewById(R.id.myView); 
    int[] attrs = new int[]{R.attr.selectableItemBackground}; 
    TypedArray typedArray = getActivity().obtainStyledAttributes(attrs); 
    int backgroundResource = typedArray.getResourceId(0, 0); 
    myView.setBackgroundResource(backgroundResource); 
} 

,並在XML文件中

<android:background="?android:attr/selectableItemBackground"> 
1

加入這一行你的項目,你是渲染適配器添加此。 android:foreground="?attr/selectableItemBackground" android:clickable="true" 您的看法

+0

我在哪裏添加?在ListView或佈局? –

+0

嘿,我已經更新了我的答案。對不起,部分答案。 – Tasneem

+0

得到了預期的結果,thanx –