为什么android:soundEffectsEnabled =" true" onClick没有播放任何声音?

时间:2017-01-11 06:32:35

标签: android android-layout

我制作了一个拨号盘网格。对于onClick数字,我想发挥一些声音效果。

这是我的XML:

<android.support.v7.widget.CardView
            android:id="@+id/cardview_1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:soundEffectsEnabled="true"
            card_view:cardCornerRadius="0dp"
            card_view:cardElevation="0dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/white"
                android:gravity="center"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/number_1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:soundEffectsEnabled="true"/>

            </LinearLayout>

        </android.support.v7.widget.CardView>

以下是代码:

@OnClick(R.id.cardview_1)
public void onClick(View v){
    ZoroHelper.zoroLogger("TAG","isSoundEffectsEnabled : "+v.isSoundEffectsEnabled()); // Gives me TRUE
    v.playSoundEffect(SoundEffectConstants.CLICK);
    // Some Action
}

也尝试过,                     view.playSoundEffect(android.view.SoundEffectConstants.CLICK);

我使用过Butterknife Library。

我找到了各种解决方案,但没有人帮助我。我哪里错了?

提前致谢。

1 个答案:

答案 0 :(得分:0)

确保您的组件中有SELECT a.name, a.travel_date, a.total FROM test_table AS a INNER JOIN ( SELECT `name`, MAX(total) AS `total` FROM test_table GROUP BY `name` ) AS b ON a.name = b.name AND a.total = b.total; android:hapticFeedbackEnabled="true"