我的主要偏好活动设置为"@android:style/Theme.Light".我的一个偏好是DialogPreference,其Dialog包含ListView.ListView的对话框为深灰色(因为DialogPreference使用AlertBuilder创建深灰色对话框),列表中的文本为黑色(因为Theme.Light导致listViews有黑色文本).是否有一种简单的方法可以使ListView的行为与黑暗对话框相同?或者让黑暗的对话框表现出与灯光活动相同的风格?
编辑:
根据Merlin的评论,似乎我应该尝试做的是创建一个LightDialog主题.为了做到这一点,我试过:1.扩展android的Theme.Light并从Theme.Dialog添加对话框属性
<style name="Theme.LightDialog" parent="@android:style/Theme.Light">
<item name="android:windowFrame">@null</item>
<item name="android:windowTitleStyle">@android:style/DialogWindowTitle</item>
<item name="android:windowBackground">@android:drawable/panel_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>
Run Code Online (Sandbox Code Playgroud)
...和2.扩展android的Theme.Dialog并添加Theme.Light的轻微属性.
<style name="Theme.LightDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/screen_background_light</item>
<item name="android:colorBackground">@android:color/background_light</item>
<item name="android:colorForeground">@androidcolor/bright_foreground_light</item>
<item name="android:colorForegroundInverse">@android:color/bright_foreground_light_inverse</item>
<item name="android:textColorPrimary">@android:color/primary_text_light</item>
<item name="android:textColorSecondary">@android:color/secondary_text_light</item>
<item name="android:textColorTertiary">@android:color/tertiary_text_light</item>
<item name="android:textColorPrimaryInverse">@android:color/primary_text_dark</item>
<item name="android:textColorSecondaryInverse">@android:color/secondary_text_dark</item>
<item name="android:textColorTertiaryInverse">@android:color/tertiary_text_dark</item>
<item name="android:textColorPrimaryDisableOnly">@android:color/primary_text_light_disable_only</item>
<item name="android:textColorPrimaryInverseDisableOnly">@android:color/primary_text_dark_disable_only</item>
<item name="android:textColorPrimaryNoDisable">@android:color/primary_text_light_nodisable</item>
<item name="android:textColorSecondaryNoDisable">@android:color/secondary_text_light_nodisable</item>
<item name="android:textColorPrimaryInverseNoDisable">@android:color/primary_text_dark_nodisable</item>
<item name="android:textColorSecondaryInverseNoDisable">@android:color/secondary_text_dark_nodisable</item>
<item name="android:textColorHint">@android:color/hint_foreground_light</item>
<item name="android:textColorHintInverse">@android:color/hint_foreground_dark</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这两种尝试均失败,因为它们使用非公共属性.有关如何创建LightDialog主题的任何建议?
在我的应用程序中,我创建文件并将其写入Sdcard.当我将Samsung Galaxy作为USB设备挂载时,我创建的文件在DDMS和Windows资源管理器中正确显示.但是,当它通过USB连接时,它们不会在我的Acer Iconia Tab A500上的Windows资源管理器中显示.我认为这是由于3.0的一些差异?我是否需要在3.0中以不同方式创建我的文件,以便它们在Windows中由usb显示?
我希望能够从我的PreferenceActivity中启动第二个Preference屏幕.在第二个首选项屏幕中,我想使用xml中的预定义布局.所以,我有两个问题:
如何使用xml布局作为首选项的布局视图?如何将此自定义首选项添加到PreferenceActivity,以便在轻触时启动?
谢谢
*编辑以回应不在犯罪现场
我试图通过声明要在xml中启动的活动,从首选项屏幕启动活动.这会导致此异常:
04-01 19:04:37.962: ERROR/AndroidRuntime(8061): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.me/CustomPrefScreen}; have you declared this activity in your AndroidManifest.xml?
Run Code Online (Sandbox Code Playgroud)
*另一个更新.但是,如果我使用Preference的某些扩展名替换了settings.xml中的PrefrenceScreen,它会覆盖onClick()以启动CustomPrefScreen,那么一切正常.
主要偏好活动:
public class MyPreferences extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
}
Run Code Online (Sandbox Code Playgroud)
的settings.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
android:summary="my summary"
android:title="my title">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.me"
android:targetClass="CustomPrefScreen"/>
</PreferenceScreen>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
mainfest文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me"
android:versionCode="1"
android:versionName="1.0">
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.NoBackground">
<activity
android:name=".MyApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category …Run Code Online (Sandbox Code Playgroud) 在我的应用中,用户选择文件.在内部,我存储有关文件的信息,我根据文件路径键入该文件.下次使用该文件时,我会处理存储的信息.麻烦的是我实例化我的文件:
File file1 = new File(Environment.getExternalStorageDirectory() + "/test.txt");
然后,在特定的JB设备上,file1.getCanonicalPath()给出:"/ storage_emulated/0/test.txt".
麻烦的是当其他应用程序在Intent中使用文件路径启动我的应用程序时,它们发送的路径往往看起来像:"/ mnt/sdcard/test.txt".
是否有明智的策略来消除这两条路径的歧义?可能我应该以不同方式实例化我的文件?
编辑:
麻烦的是,两个文件的两个canaonical路径不相等.对于以下,cp1=="mnt/sdcard/test/txt"和cp2=="/storage/emulated/0/text/txt":
File file1 = new File("/mnt/sdcard/test.txt");
File file2 = new File("/storage/emulated/0/test.txt");
String cp1 = file1.getCanonicalPath();
String cp2 = file2.getCanonicalPath();
Run Code Online (Sandbox Code Playgroud) 我的应用程序意外死亡,没有明显的异常.崩溃在我的三星Galaxy Tab和我的模拟器上一直发生; 虽然logcat输出因设备而异.我怀疑它与垃圾收集有关,但无法从logcat收集任何东西.有任何想法吗?
在2.2模拟器上死亡的Logcat输出:
03-16 15:17:44.104: INFO/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-16 15:17:44.104: INFO/DEBUG(31): Build fingerprint: 'generic/sdk/generic/:2.2/FRF91/43546:eng/test-keys'
03-16 15:17:44.104: INFO/DEBUG(31): pid: 283, tid: 283 >>> com.myapp<<<
03-16 15:17:44.114: INFO/DEBUG(31): signal 11 (SIGSEGV), fault addr deadbaad
03-16 15:17:44.114: INFO/DEBUG(31): r0 00000000 r1 0000000c r2 00000027 r3 00000000
03-16 15:17:44.114: INFO/DEBUG(31): r4 00000000 r5 deadbaad r6 00001728 r7 fdff3fdc
03-16 15:17:44.124: INFO/DEBUG(31): r8 be965788 r9 00000000 10 be964fc8 fp 00000002 …Run Code Online (Sandbox Code Playgroud) 我需要通过一组顶点画一条平滑的线.该组顶点是由用户在触摸屏上拖动他们的手指来编译的,该组趋于相当大并且顶点之间的距离相当小.但是,如果我只是用一条直线连接每个顶点,结果非常粗糙(不平滑).
我找到了使用样条插值(和/或其他我不理解的东西)的解决方案,通过添加一堆额外的顶点来平滑线条.这些工作很好,但由于顶点列表已经相当大,因此将其增加10倍左右会产生重大的性能影响.
看起来平滑应该可以通过使用贝塞尔曲线而不添加额外的顶点来实现.
以下是基于此解决方案的一些代码:
http://www.antigrain.com/research/bezier_interpolation/
当顶点之间的距离很大时,它很有效,但当顶点靠近在一起时,它不能很好地工作.
有没有更好的方法通过大量顶点绘制平滑曲线而不添加额外顶点的建议?
Vector<PointF> gesture;
protected void onDraw(Canvas canvas)
{
if(gesture.size() > 4 )
{
Path gesturePath = new Path();
gesturePath.moveTo(gesture.get(0).x, gesture.get(0).y);
gesturePath.lineTo(gesture.get(1).x, gesture.get(1).y);
for (int i = 2; i < gesture.size() - 1; i++)
{
float[] ctrl = getControlPoint(gesture.get(i), gesture.get(i - 1), gesture.get(i), gesture.get(i + 1));
gesturePath.cubicTo(ctrl[0], ctrl[1], ctrl[2], ctrl[3], gesture.get(i).x, gesture.get(i).y);
}
gesturePath.lineTo(gesture.get(gesture.size() - 1).x, gesture.get(gesture.size() - 1).y);
canvas.drawPath(gesturePath, mPaint);
}
}
}
private float[] getControlPoint(PointF p0, PointF p1, PointF p2, PointF p3)
{ …Run Code Online (Sandbox Code Playgroud) 我希望我的TextView在按下时使用不同的颜色背景进行绘制.下面的xml包含一个Button和TextView,它们都指定一个Selector作为背景.Button按预期工作,但TextView在按下时不会改变颜色.有没有办法使这个工作为TextView?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:text="temporary text view"
android:layout_width="wrap_content"
android:layout_height="100dip"
android:background="@drawable/blackselector"
/>
<Button
android:text="temporary button"
android:layout_width="wrap_content"
android:layout_height="100dip"
android:background="@drawable/blackselector"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<color android:color="#FF0000" />
</item>
<item>
<color android:color="#00FF00" />
</item>
</selector>
Run Code Online (Sandbox Code Playgroud) 当我打开带有很长行的文件时,IntelliJ 强行换行并给出此消息this document contains very long lines. soft wraps were forcibly enabled to improve editor performance。
按照此链接中的说明,我在常规编辑器设置中禁用了软包装,并使用帮助菜单创建了一个 idea.properties 文件,在其中添加了'editor.soft.wrap.force.limit=nnnnn.
但是,除非我在活动编辑器中明确禁用它们,否则 intellij 会继续包装这些行。有什么建议?
我需要aurora_replica_read_consistency在我的 Nodejs 应用程序的每个 Sequelize 连接上设置一个 Mysql 会话变量 ( )。
我可以使用下面的代码设置此会话变量,但我很确定不会为所有 Sequelize 连接设置此变量,我需要一种在每次打开新的数据库连接/将其添加到连接池时设置此变量的方法。
await sequelize.query("set aurora_replica_read_consistency = 'eventual'");
Run Code Online (Sandbox Code Playgroud)
有没有办法在我的 Sequeilize 实例上配置此会话变量,或者扩展/覆盖 Sequelize 以便我可以在每次创建新连接时进行设置?
我在市场上列出了两个应用程序.其中一个是免费的演示应用程序,第二个是解锁第一个应用程序完整版本的第二个关键应用程序.我收到一个用户的报告说该演示安装在他们的华为上,但市场将他们的应用程序列为"不兼容".我还没有收到任何其他报告,也没有在Google上找到任何有用的内容.下面是两个清单xmls,首先是演示应用程序,第二个是关键应用程序.这可能是由检查许可证权限引起的吗?在Android市场开发者控制台中,"支持的设备"部分对于两个应用程序完全相同:
支持的设备[了解更多]此应用程序仅适用于具有这些功能的设备,如应用程序清单中所定义.
屏幕布局:SMALL NORMAL LARGE XLARGE
所需的设备功能android.hardware.touchscreen
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="..."
android:versionCode="3"
android:versionName="1.1">
<application ...>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=...
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7"/>
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<application ...
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)