我的Nexus 4升级到4.4,现在每当MediaPlayer发出声音时,我都会收到警告:
Should have subtitle controller already set
Run Code Online (Sandbox Code Playgroud)
而且在打电话给mp.release()我时,我现在得到警告
mediaplayer went away with unhandled events
Run Code Online (Sandbox Code Playgroud)
使用4.3的Nexus 7上的相同应用程序不会显示这些警告.
为了使用支持操作栏,我的活动必须扩展ActionBarActivity,当我这样做并启动活动时,应用程序崩溃:
例外:您需要在此活动中使用Theme.AppCompat主题(或后代).
在我的styles.xml中,我有
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light"></style>
Run Code Online (Sandbox Code Playgroud)
在我的AndroidManifest.xml中,我有违规行为
<activity android:name="com.example.test3.SettingsActivity"
android:theme="@style/AppBaseTheme" />
Run Code Online (Sandbox Code Playgroud) I'm trying to add the support action bar to my Android app, but right at the start where I have
<style name="AppBaseTheme" parent="android:Theme.AppCompat.Light">
Run Code Online (Sandbox Code Playgroud)
I get an error No resource found that matches the given name: android:Theme.AppCompat.Light.
I can import android.support.v7.app.ActionBar and android.support.v7.app.ActionBarActivity so I think I've added the support libraries correctly. Why do Android dev docs gloss over this? It should be Lesson #1.
我确定我误解了一些基本的东西,但为什么styles.xml文件夹中的文件values-v14适用于运行Jelly Bean 4.3(API级别18)的设备?
如何从Button视图中删除填充?至少我需要在所有方面都有相同的填充,无论如何.
我有这个
<Button
style="@style/btnStart"
android:text="@string/start" />
Run Code Online (Sandbox Code Playgroud)
而这种风格
<style name="btnStart" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/selector_start_button</item>
<item name="android:textColor">@drawable/selector_start_button_text</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">24sp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
而且这很抽象 selector_start_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="@color/start_button" />
<stroke android:color="@color/start_button" android:width="1dp" />
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#00000000" />
<stroke android:color="@color/start_button" android:width="1dp" />
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp" />
</shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
但我仍然得到这个

在我的应用程序中,我希望在用户当前正在运行的任何活动中弹出某些信息.Toast适用于简单的文本(它可以覆盖每个活动,可以从任何地方调用),但我想要更精细的东西.创建我需要显示的信息的方法是在Application基类中而不是任何特定的活动.
我能用我所知道的唯一方法是让Application类发送一个广播然后让活动显示一个对话框,但这需要修改所有活动并复制大量代码.
我确信有一种更聪明的方法可以做到这一点,但我还不了解Android.