在我的应用程序,我使用的按键声音池点击音频效果。 问题是,如果在设备的设置声音选择打勾,然后我的按钮会产生两个声音:系统中的一个,我的一个在同一时间
In my application I am using sound pool for the button click audio effect. The problem is that if in the device's settings "Audible selection" is ticked, then my buttons will produce two sounds: the system one and my one at the same time.
看来,如果在每个按钮的属性我设置音效已启用设置为false,系统听不到声音了。但我有许多按钮在整个活动一打,再加上我加入的code按键矩阵,所以它是相当不方便手动设置启用音效为false,他们每个人。不知道我是怎么做到这一点的code ..
It seems that if in each button properties I set "Sound Effects Enabled" to false, the system sound is not heard any more. But I have many buttons across a dozen of activities, plus I am adding a matrix of buttons in code, so it is rather inconvenient to set "Sound Effects Enabled" to false manually for each one of them. Not sure how I do this in code..
有没有停止声音选择我的应用程序,或者至少在一个活动更具全球性的方式?
Is there a more global way to stop "Audible selection" in my application or at least for the one activity?
创建主题文件RES /价值/ styles.xml
Create a theme file "res/values/styles.xml"
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.Black.NoTitleBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:soundEffectsEnabled">false</item>
</style>
</resources>
,然后引用它在你的的AndroidManifest.xml
And then reference to it in your "AndroidManifest.xml"
<application
...
android:theme="@style/AppTheme" >