我尝试了多种方法,这是其中之一:
System.Globalization.DateTimeFormatInfo format = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat;
return dt.Value.ToString (format.ShortTimePattern);
Run Code Online (Sandbox Code Playgroud)
这个问题是.NET 3.5返回"." 作为时间分隔符,这很可能是一个错误(因为我的挪威语区域使用冒号) :.NET(3.5)格式化时间使用点而不是冒号作为它的IT文化的TimeSeparator?
我也看了一下: 在iPhone上检索当前的当地时间?
但MT在NSDateFormatter上似乎没有setTimeStyle?
那么,任何人都有任何魔术伎俩?
我的目标是输出:
21:00/9:00 PM
10:09/10:09 AM
喜欢iPhone中的状态栏.
我有一个支持 RTL 的应用程序。当格式化两个团队之间的分数时,我会写下以下内容:
\n\nt1.setText(String.format(Locale.forLanguageTag("ar-MA"), "%d - %d", 1, 0));\nRun Code Online (Sandbox Code Playgroud)\n\n如果我的文本字段设置为 textDirection="locale",在运行 Android 8 和 Android 9 的所有测试设备上、在我的华为上以及基本上在任何地方,它都会在 Android 模拟器上输出“0 - 1”。但如果我在运行 Android 8.0 的三星 S7 上进行测试,它会返回“1 - 0”。我在物理设备和三星设备实验室上进行了测试:https ://developer.samsung.com/remotetestlab/rtlDeviceList.action
\n\n这是错误的做法吗?当我有一个包含乐谱的文本字段时,如何格式化乐谱,使其在所有设备上的 LTR 和 RTL 上都可以使用?这在大多数设备上都能完美运行,但我似乎遗漏了一些关于它在三星设备上崩溃的原因。
\n\n这是我的代码:
\n\n<?xml version="1.0" encoding="utf-8"?>\n<LinearLayout\n xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:app="http://schemas.android.com/apk/res-auto"\n xmlns:tools="http://schemas.android.com/tools"\n android:orientation="vertical"\n android:layout_width="match_parent"\n android:layout_height="match_parent"\n tools:context=".MainActivity"\n tools:showIn="@layout/activity_main">\n\n <TextView\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:text="Home team won 1-0"/>\n\n <TextView\n android:id="@+id/t1"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layoutDirection="locale"\n android:text="1-0"\n />\n <TextView\n android:id="@+id/t2"\n android:layoutDirection="rtl"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:text="1-0"\n />\n <TextView\n android:id="@+id/t3"\n android:textDirection="locale"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:text="1-0"\n />\n …Run Code Online (Sandbox Code Playgroud) 我们在appstore中有一个应用程序在iPhone 4g/4gs上没有任何问题,但是当我在iPod上测试时,我得到了一个惊喜,因为它在"随机"地方一直崩溃.看着strack的痕迹,我的视觉控制器似乎已经过了GC.
如果我写这样的方法,viewcontroller会被垃圾收集:
public void PushShowTeamController (Object a)
{
var teamController = new TeamController (a);
NavigationController.PushViewController (teamController, true);
}
Run Code Online (Sandbox Code Playgroud)
因为iPod突然抛出这样的错误:
Jan 6 18:52:09 unknown MyApp[5197] <Warning>: Received memory warning.
Jan 6 18:52:10 unknown UIKitApplication:mypackage.app[0x9db2][5197] <Notice>: Unhandled Exception: System.Exception: Selector invoked from objective-c on a managed object that has been GC'ed ---> System.MissingMethodException: No constructor found for MyApp.TeamController::.ctor(System.IntPtr)
Jan 6 18:52:10 unknown UIKitApplication:mypackage.app[0x9db2][5197] <Notice>: at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename …Run Code Online (Sandbox Code Playgroud) 我使用了Google IO repo中的代码:https: //github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java
我正在尝试在向上滚动时隐藏工具栏并且它工作得很好,但我的问题是当工具栏动画显示在屏幕外时我的主要内容保持固定.
在R.id.toolbar_actionbar上运行动画的代码是:
view.animate()
.translationY(-view.getBottom())
.alpha(0)
.setDuration(HEADER_HIDE_ANIM_DURATION)
.setInterpolator(new DecelerateInterpolator());
Run Code Online (Sandbox Code Playgroud)
我已经尝试将工具栏放在带有内容的线性布局中,但它没有改变任何东西.只有当我将操作栏设置为visibility = gone时,内容才会向上移动.
有没有人知道我必须做些什么来使内容与工具栏的翻译动画一起动画?
基本上问题归结为:我如何设置一个视图的位置并使其他视图具有动画效果?
谷歌IO代码似乎只是为工具栏设置动画,其余的内容使用它动画,但我无法让它工作.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_actionbar" />
<FrameLayout
android:id="@+id/main_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/adsContainer"
android:layout_below="@+id/toolbar_actionbar" />
<LinearLayout
android:id="@+id/adsContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#000000"
android:orientation="horizontal" />
</RelativeLayout>
<!-- The navigation drawer -->
<ExpandableListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud) 以前我使用setSound(null)但是使用新的通知通道这不起作用.
所以我可以创建另一个通道(已经有大约10个)来说明Notification Updates并将其设置为声音的空值?这是解决这个问题的唯一方法吗?如果用户足够愚蠢(总有一些)为此类别设置声音,我们会在更新现有警报时获得多个声音.
我正在尝试构建我的自定义通知,但我的一切正常,但我的布局在流卡中被切断了.似乎它设法在流卡中显示我的整个自定义布局,即使我只使用大约50%的屏幕高度.但我看到其他自定义布局,例如Google Now的体育卡比我的大.
所以我尝试将我的RelativeLayout包装在CardScrollView中(不确定它会有帮助)但是当我运行该代码时,Wear设备崩溃:
java.lang.RuntimeException: Unable to start activity ComponentInfo ...
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CardScrollView" on path: DexPathList[[zip file "/data/app/com.myapp.apk"],nativeLibrary...
Run Code Online (Sandbox Code Playgroud)
我的gradle文件如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何解决这个错误,我已经尝试清理项目并重新安装应用程序,但错误仍然存在.有人成功使用过这些布局吗?
https://developer.android.com/training/wearables/apps/layouts.html