对MaterialRippleLayout
或TextView
或Botton
项等小部件使用ListView
库后,点击事件已停用。例如,在下面的xml布局按钮单击不工作,我无法获得onclick的回调。
<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button" />
</com.balysv.materialripple.MaterialRippleLayout>
此代码不起作用:
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.e("Button Clicked !!","");
}
});
答案 0 :(得分:0)
我发现了问题。我必须将此代码用于listview项目:
app:mrl_rippleInAdapter="true"
示例:
<com.balysv.materialripple.MaterialRippleLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:mrl_rippleColor="#8d575757"
app:mrl_rippleInAdapter="true"
app:mrl_rippleDuration="250"
app:mrl_rippleFadeDuration="25" >
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="7dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_drawer_group_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:id="@+id/imgDrawerItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</com.balysv.materialripple.MaterialRippleLayout>