私はダイヤルパッドのグリッドを作っています。 onClickの数字の場合、私はいくつかの効果を演奏したい。ここでなぜandroid:soundEffectsEnabled = "true"は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を使用しました。
私はさまざまな解決策を見つけましたが、誰も助けてくれません。どこが間違っていますか?
ありがとうございました。
携帯電話の設定を確認し、サウンドオプションがオンになっているかどうかを確認します。 –
私はサウンドオプションのために私の電話設定をチェックして、彼らはオンです。他のアプリは私の電話でonClickのサウンドを再生しますが、私のアプリはサウンドエフェクトを再生しません。 – Kesha