我刚刚创建了示例BB应用程序,可以选择日期.
DateField curDateFld = new DateField("Choose Date: ",
System.currentTimeMillis(), DateField.DATE | DateField.FIELD_LEFT);
Run Code Online (Sandbox Code Playgroud)
选择日期后,我需要将该long值转换为String,以便我可以轻松地将日期值存储在数据库中的某个位置.我是Java和Blackberry开发的新手.
long date = curDateFld.getDate();
Run Code Online (Sandbox Code Playgroud)
我应该如何将这个长值转换为String?另外我想从String转换回long.我觉得我能用long l = Long.parseLong("myStr");
吗?
我的项目无法使用持续时间的Gauva库进行编译,因为它似乎是用Java 1.8编译的,我在我的项目中使用Java 1.7.
哪个版本的Guava与Java 1.7兼容?
查看和断言listview是android espresso的预期大小的最佳方法是什么?
我写了这个匹配器,但不太清楚如何将它集成到测试中.
public static Matcher<View> withListSize (final int size) {
return new TypeSafeMatcher<View> () {
@Override public boolean matchesSafely (final View view) {
return ((ListView) view).getChildCount () == size;
}
@Override public void describeTo (final Description description) {
description.appendText ("ListView should have " + size + " items");
}
};
}
Run Code Online (Sandbox Code Playgroud) 这似乎是正确的......
onView (withId (R.id.menu_delete)).check (matches (not (isDisplayed ())));
Run Code Online (Sandbox Code Playgroud)
...但它抛出了这个异常:
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.just10.android:id/menu_delete
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:com.github.ksoichiro.android.observablescrollview.ObservableListView{3169f0f3 VFED.VC. .F...... 0,0-480,724 #102000a android:id/list}
Run Code Online (Sandbox Code Playgroud)
不应该显示断言视图的最佳方法是什么?
如果在遵循通知时应用程序不在内存中,我就会遇到问题.不会创建backstack.我按照开发人员指南按照步骤操作.请告诉我我错过的位,否则我将必须通过我的所有意图路由HomeActivity
,以便按照以下意图手动创建backstack.
AndroidManifest.xml:
<activity
android:name=".activity.HomeActivity"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:icon="@drawable/actionbar_logo"
android:label="@string/activity_label_home"
android:launchMode="singleTask"
android:parentActivityName=".activity.Start"
android:windowSoftInputMode="stateAlwaysHidden" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.Start" />
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.ChatActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:label="@string/activity_label_in_chat"
android:parentActivityName=".activity.HomeActivity"
android:windowSoftInputMode="stateHidden"
tools:ignore="UnusedAttribute" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.HomeActivity" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.myapp.chat" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
建筑通知:
final String chatId = cursor.getString(cursor.getColumnIndexOrThrow(MessageColumns.CHAT));
final Intent chat = new Intent(c, ChatActivity.class);
chat.putExtra(ChatActivity.EXTRA_CHAT_ID, chatId);
PendingIntent intent = TaskStackBuilder.create(c).addNextIntentWithParentStack (chat).getPendingIntent (0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder (c);
final NotificationManagerCompat …
Run Code Online (Sandbox Code Playgroud) 我想在悬停时更改按钮的颜色.
这是我的xaml代码.
<Window x:Class="OfflineIM.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Vytru | Offline IM" Height="300" Width="550" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Icon="/OfflineIM.UI;component/Images/368x368.ico">
<Grid Name="MainGrid">
<Grid Name="HeaderGrid" VerticalAlignment="Top" HorizontalAlignment="Center" Width="550" Height="130">
<Image VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="250" Margin="5,10,10,10" Source="Images\offlineIM-logo.png" />
</Grid>
<Grid Name="ContentGrid" VerticalAlignment="Bottom" HorizontalAlignment="Center" Height="160" Width="550">
<Grid Margin="20,10,20,80" Background="#5F68686A">
<TextBlock Margin="170,5,20,10" VerticalAlignment="Top" HorizontalAlignment="Left" Text="" Name="companyNameTextBlock" Foreground="#FF2B2D2E" TextAlignment="Justify" FontSize="12" FontWeight="Normal" />
<TextBlock Margin="5,5,20,10" VerticalAlignment="Top" HorizontalAlignment="Left" Text="Company Name:" Foreground="#FF2B2D2E" TextAlignment="Justify" FontSize="12" FontWeight="Normal" />
<TextBlock Margin="5,25,20,10" VerticalAlignment="Top" HorizontalAlignment="Left" Text="Number of Users:" Foreground="#FF2B2D2E" TextAlignment="Justify" FontSize="12" FontWeight="Normal" />
<TextBlock Margin="170,25,20,10" VerticalAlignment="Top" HorizontalAlignment="Left" Text="" Name="NumberOfUsersTextBlock" …
Run Code Online (Sandbox Code Playgroud) 为了测试目的,我已将红色LED灯用于通知,但是...
我是否需要检查设备是否具有LED(如果该设备不具有此功能),以及如何做到这一点?另外,LED颜色是否已预先确定?
我试图找到一些文档或主题来给我这些问题的答案,但是没有运气...
在Android Studio中使用Gradle来压缩库时,Proguard遇到了Lombok库的问题.我找到了一些配置信息来修复butterknife,我们使用的另一个注释库.
-keepattributes *Annotation*
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}
Run Code Online (Sandbox Code Playgroud)
有没有人知道要添加的标志让Lombok开心.
Proguard配置文件
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags …
Run Code Online (Sandbox Code Playgroud) 我有一个数据驱动的集线器部分,可以很好地填充图像.视图模型包含我想要显示为工具提示的文本,但无法弄明白.
这是重要的片段:
<HubSection x:Uid="MyHub" x:Name="MyHubSection" Width="311">
<HubSection.Header>
<TextBlock x:Uid="HubMSectionHeader"
Style="{StaticResource MainHubSectionHeaderStyle}" Text="Friends"/>
</HubSection.Header>
<DataTemplate>
<StackPanel>
<Button x:Name="InviteButton" Content="Send Invite" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="InviteButton_Click"/>
<StackPanel >
<Grid>
<GridView ItemsSource="{Binding Friends}" Background="{ThemeResource HubBackground}" x:Name="FriendGrid" >
<GridView.ItemTemplate >
<DataTemplate>
<Image Source="{Binding ProfilePhotoBitmap, Mode=TwoWay}" Height="100" Opacity="1" Stretch="Uniform" Tapped="Friend_Tapped"/>
<ToolTipService.ToolTip>
<TextBlock Text="{Binding FullName}"/>
</ToolTipService.ToolTip>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
</StackPanel>
</StackPanel>
</DataTemplate>
</HubSection>
Run Code Online (Sandbox Code Playgroud) 正如您所看到的,背景在弹出窗口后面扭曲了.它只发生在棒棒糖上!请不要被我的样式文件中的所有x_弄糊涂.我刚刚对代码进行了去标记.
在主题文件中:
<style name="core" parent="Theme.AppCompat.Light">
<!-- Popup menu -->
<item name="android:popupMenuStyle">@style/x_popup_menu_theme</item>
<item name="android:textAppearanceSmallPopupMenu">@style/x_popup_menu_small_text</item>
<item name="android:textAppearanceLargePopupMenu">@style/x_popup_menu_large_text</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在v21/themes_styles.xml中
<style name="x_popup_menu_theme" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@color/x_navy_dark</item>
</style>
<style name="x_popup_menu_large_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
<item name="android:textColor">@color/std_white</item>
</style>
<style name="x_popup_menu_small_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
<item name="android:textColor">@color/std_white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如果我更改/删除样式,它的工作原理如下图所示.
<style name="x_popup_menu_theme" parent="Widget.AppCompat.PopupMenu">
</style>
<style name="x_popup_menu_large_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
</style>
<style name="x_popup_menu_small_text" parent="TextAppearance.AppCompat.Widget.PopupMenu.Small">
</style>
Run Code Online (Sandbox Code Playgroud) 我需要做大约5个链接请求,例如我有5个不同的调用,我想让它们按特定顺序串行不平行.
以下是我的观察结果的一些例子
Observable<ResponseBody> textsCall=EndpointFactory.provideEndpoint().getTexts(textsTask.getLanguage())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
Observable<AirportCombo> routesCall=EndpointFactory.provideEndpoint().getRoutes()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)
实际上,我不知道rx java上有什么功能.
早先我已经实现了并行请求,现在我需要串行.
如果您需要并行方法,您可以:
Observable<ResponseResult> combined = Observable.zip(textsCall, routesCall, (textsBody, airportCombo) -> {
//some parsing and other logic
return new ResponseResult(flag);
});
Run Code Online (Sandbox Code Playgroud)