我知道,对Context.getTheme(),它通常不能很好地工作,如果我们使用Application的Context
MyApplication.singletonInstance().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId will be 0x0, which is invalid
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用Activity上下文,它运作良好
MyFragment.this.getActivity().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId is valid
Run Code Online (Sandbox Code Playgroud)
我想知道为什么我们无法通过解析属性Application?
在清单中,我们在Application级别上找到特定的主题信息.所以,我认为从Application对象中获取主题确实有意义.
<application
android:theme="..."
Run Code Online (Sandbox Code Playgroud) 通过应用list_selector_holo_light.xml线性布局的背景(在ListView中没有使用),我想我可以通过长按它来实现发光的动画效果.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/list_focused_holo" />
</selector>
Run Code Online (Sandbox Code Playgroud)
但是,我没有看到过渡动画效果,从浅蓝色过渡到深蓝色.
还有什么我错过了吗?
目前,我有
private ThreadLocal<DateFormat> shortDateFormat = new ThreadLocal<DateFormat>() {
@Override protected DateFormat initialValue() {
final DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
return format;
}
};
Run Code Online (Sandbox Code Playgroud)
使用我的Android 4.1,这为我提供了日期格式(在我的本地化.对于其他国家可能看起来不同)
19/07/2013
但是,有时我希望有一个更短的版本,如19/07/13
我不想硬编码
DD/MM/YY
由于上述方式不能在不同国家之间移植.有些国家,他们的月份是在约会之前.
有没有可行的方法来实现这一目标?
p/s不仅是月/日订单.可能还有其他问题.例如,中国正在使用19-07-13或19-07-2013.其他国家可能会有更多边缘案例,但我不知道.
我用的是最新的adt-bundle-windows-x86_64-20130717,与
我曾尝试在仿真器2.3.3上安装应用程序,包括ARM和Intel.但是,它不再起作用(在我使用最新的adt之前,它曾经在我的同一台Win64机器上工作)
Installation error: INSTALL_FAILED_DEXOPT
Please check logcat output for more details.
Launch canceled!
Run Code Online (Sandbox Code Playgroud)
我的模拟器设置如下.

我曾经按照如何解决INSTALL_FAILED_DEXOPT这个错误?.这对我的情况没有帮助.
请注意,4.1.2的仿真器对Intel非常有效.我甚至尝试通过电子邮件发送APK,然后从模拟器下载 - >安装.但是,这就是我所得到的Application not installed

解决这个问题的任何解决方法?
我的logcat正在进行此类日志记录
E/PackageManager(855): Package org.yccheok.jstock.gui has mismatched uid: 10031 on disk, 10033 in settings
E/dalvikvm(1241): LinearAlloc exceeded capacity (5242880), last=468
E/dalvikvm(1241): VM aborting
E/installd(798): dexopt failed on '/data/dalvik-cache/data@app@org.yccheok.jstock.gui-1.apk@classes.dex' res = 11
Run Code Online (Sandbox Code Playgroud)
注意,如果我使用的是模拟器4.1.2,则不会出现此问题
目前,我有一个 Android 项目,由 1 个主项目和多个库项目组成。
就在最近,我意识到如果主项目和库项目之间有相同的布局文件名,可能会发生不好的事情。
third-party-library-project
- res
- layout
- actionbar_custom_view_done_discard.xml
main-project
- res
- layout
- actionbar_custom_view_done_discard.xml
Run Code Online (Sandbox Code Playgroud)
因此,如果在 中third-party-library-project,如果您在其活动中有一行代码,
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_discard, null);
Run Code Online (Sandbox Code Playgroud)
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.yccheok.jstock.gui/group.pals.android.lib.ui.lockpattern.LockPatternActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: …Run Code Online (Sandbox Code Playgroud) 我想在新的Android应用程序即开发中使用特殊应用程序数据文件夹中的文件(又名drive.appdata范围).
谷歌的那些人在与Google Play Services 4.2捆绑在一起的新版Google云端硬盘Android API中做得非常出色.
但我发现它不可能在Android API中使用appdata文件夹,因为只有范围drive.file.现在我必须在android中使用通用的java/web api.
有计划在android API中实现drive.appdata范围吗?什么时候 ?
提前致谢
由于我AlarmManager用于执行定期小部件更新,因此我需要确保onEnabled并onDisabled可靠地工作。
但是,我意识到它们有时不会被触发。我不是唯一面临这个问题的人。
Android appWidgetProvider onEnabled 从未在平板电脑上调用
onDisabled吗,尤其是?因为我不希望 AlarmManager 在最后一个小部件被删除后仍被重复触发。 <receiver android:name="org.yccheok.MyAppWidgetProvider"
android:exported="true" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.appwidget.action.APPWIDGET_ENABLED" />
<action android:name="android.appwidget.action.APPWIDGET_DELETED" />
<action android:name="android.appwidget.action.APPWIDGET_DISABLED" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
Run Code Online (Sandbox Code Playgroud)
public class MyAppWidgetProvider extends AppWidgetProvider {
private static PendingIntent createAlarmUpdatePendingIntent(Context context) {
Intent intent = new Intent(context, JStockAppWidgetProvider.class);
intent.setAction(JStockAppWidgetProvider.ALARM_UPDATE_ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
return pendingIntent;
}
@Override
public void onEnabled(Context context) …Run Code Online (Sandbox Code Playgroud) 目前,我正在将JavaFX集成到Swing中.
Platform.setImplicitExit(false)由于在Swing中处理JFXPanel时出现JavaFX IllegalStateException,我需要使用
public class MainFrame extends javax.swing.JFrame {
private void formWindowClosed(java.awt.event.WindowEvent evt) {
Platform.exit();
}
public static void main(String args[]) {
Platform.setImplicitExit(false);
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道,我是否应该避免重新创作JFXPanel呢?每次我想展示JDialog哪个拥有JFXPanel?为了避免可能的JavaFX资源泄漏,我应该使用
public class SimpleSwingBrowser extends JDialog {
// Avoid JFXPanel re-creation.
private static final JFXPanel jfxPanel = new JFXPanel();
}
Run Code Online (Sandbox Code Playgroud)
要么
public class SimpleSwingBrowser extends JDialog {
private final JFXPanel jfxPanel = new JFXPanel();
}
Run Code Online (Sandbox Code Playgroud) 我有
<action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" /><action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" />当我使用Eclipse构建和运行具有多个库项目的单个主项目时,将只安装1个应用程序.
但是,如果我迁移到Android Studio以构建和运行具有多个库项目的单个主项目,则将安装多个应用程序,
取决于有多少项目(无论主要项目或图书馆项目)定义<action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" />
我想知道,在构建和运行项目时,是否有任何我在Android Studio中做错的配置,这会导致安装多个应用程序?
目前,我唯一的解决方法是从所有库项目中删除这些行(<action android:name="android.intent.action.MAIN" />和<category android:name="android.intent.category.LAUNCHER" />)AndroidManifest.xml.这是在Android Studio中导入项目库的常见和正确方法吗?与在Eclipse中一样,这些行不会在我的设备中安装额外的应用程序.
这就是我的项目结构的样子

如您所见,第一个文件夹图标看起来与其他文件夹图标不同.我想这表明,第一个文件夹图标是主项目,其他是图书馆项目.
如果只有一个主项目,为什么可以安装多个应用程序?
产生耗时的计算线程是很常见的.之后,我们需要更新Activity或Fragment计算结果.
一直以来,我遵循以下准则.到目前为止,它对我很有用.
setRetainInstance(true)UI片段.setTargetFragment和getTargetFragment技术setRetainInstance(true)UI片段.onAttach和onDetach存储引用Activity.谷歌似乎不鼓励使用getActivity.http://developer.android.com/guide/components/fragments.html但是,从一个类派生的情况怎么样View?我计划AsyncTask从自定义启动View.但是,我怎么能onPostExecute回到View?
我之所以这么说的原因是,在我的自定义视图中,某些触摸事件会触发它使用新的位图重绘自身.生成新位图非常耗时.因此,我计划启动AsyncTask,生成这样的位图,然后传回自定义View.但是,配置更改可能会导致重新创建自定义View.因此,我需要确保我的AsyncTask可以在期间具有正确的View引用onPostExecute.