我正在使用该包react-native-localize在应用程序中提供本地化。我已经链接了该库,它可以在设备上正常运行。
问题:
当我测试导入react-native-localize的组件时。我收到错误react-native-localize: NativeModule.RNLocalize is null。为了解决这个空错误,我jest.mock('react-native-localize');在测试文件的顶部调用。但我仍然收到指向NativeModule.RNLocalize is null. 我还提供了README 包中提到的模拟,但无济于事。
import 'react-native';
import React from 'react';
import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import * as RNLocalize from 'react-native-localize';
// mocking the module here with jest.mock
jest.mock('react-native-localize');
it('renders correctly', () => {
renderer.create(<App />);
});
Run Code Online (Sandbox Code Playgroud)
题:
如何解决测试中的 NativeModule.RNLocalize is null 错误?
测试堆栈跟踪:
FAIL __tests__/App-test.js
? Test suite failed …Run Code Online (Sandbox Code Playgroud) 我正在尝试将输入验证添加到用户输入数值的三个EditTexts集合中.我面临的问题是计算工作,用户不能输入零作为输入字段之一或应用程序将崩溃.
我试图实现以下内容以防止输入零并显示警告消息.我收到一条错误,指出"无法启动活动calcResult"这是显示计算的活动.
这是错误日志的链接:http://pastebin.com/hDsabjR6
我从中了解到零值仍然在验证中滑落,但我不知道为什么?
String getoffsetlength = offsetLength.getText().toString();
if (getoffsetlength.trim().equals('0')) {
Toast.makeText(this, "Enter number greater than 0!", Toast.LENGTH_SHORT).show();
return;
}
Run Code Online (Sandbox Code Playgroud)
当我在app中使用此验证时,应用程序崩溃了.关于我搞砸了这个实现的哪些想法?
我有一个Kinect传感器的视频输入,该传感器由存储为位图的图像托管.我的问题是如何将图像叠加.png到视频输入上.
视频输入显示如下图所示为位图源,我知道如何在位图上绘制一条线但是如何从资源中绘制图像呢?
KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96,
PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel);
Run Code Online (Sandbox Code Playgroud)
下面是通过将图像放在视频源上来模拟我想要实现的目标:

更新了绘图方法的实现,我不认为这是正确的实现我在添加图像路径时得到无效的参数错误.DrawImage:
void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame == null) return;
byte[] colorData = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo(colorData);
KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96,
PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel);
Rect destRect2;
//drawing image overlay to video feed
var drawingVisual = new DrawingVisual();
var drawingContext = drawingVisual.RenderOpen();
drawingContext.DrawImage(BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, colorData, colorFrame.Width …Run Code Online (Sandbox Code Playgroud) 我已将 Java 控制台应用程序导出到 Jar 文件,但是当我运行 jar 并调用在 JSON 文件中解析的代码时,我得到一个 java.lang.IllegalArgumentException
有谁知道当我将程序作为 JAR 运行时为什么会抛出异常?当应用程序从 Eclipse 运行时,解析工作正常。
这是我执行 jar 文件并调用解析 JSON 文件的代码时输出的确切错误:
Exception in thread "main" java.lang.IllegalArgumentException: URI is not hierar
chical
at java.io.File.<init>(Unknown Source)
at gmit.GameParser.parse(GameParser.java:44)
at gmit.Main.main(Main.java:28)
Run Code Online (Sandbox Code Playgroud)
这是在我的 GameParser 类中进行解析的方式:
public class GameParser {
private static final String GAME_FILE = "/resources/game.json";
private URL sourceURL = getClass().getResource(GAME_FILE);
private int locationId;
private List<Location> locations;
private List<Item> items;
private List<Character> characters;
public void parse() throws IOException, URISyntaxException {
ObjectMapper mapper = new ObjectMapper(); …Run Code Online (Sandbox Code Playgroud) 我将一个可观察的模型对象集合绑定到数据网格.但是当我设置绑定到集合时,我得到了一个路径错误的peoprties.
在调试此问题时,我检查了CustomerModel中的公共属性是否在DataGrid绑定中正确命名.而且返回到模型的集合也不是空的.我还检查了后面的View代码中是否正确设置了数据上下文.
我认为这可能是一个错误,因为我在xaml中指定了绑定路径的方式.
对于每个字段,绑定错误的完整详细信息如下:
System.Windows.Data Error: 40 : BindingExpression path error: 'FirstName' property not found on 'object' ''MainViewModel' (HashCode=55615518)'. BindingExpression:Path=FirstName; DataItem='MainViewModel' (HashCode=55615518); target element is 'TextBox' (Name='fNameTbx'); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'LastName' property not found on 'object' ''MainViewModel' (HashCode=55615518)'. BindingExpression:Path=LastName; DataItem='MainViewModel' (HashCode=55615518); target element is 'TextBox' (Name='lNameTbx'); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'Email' property not found on 'object' ''MainViewModel' (HashCode=55615518)'. BindingExpression:Path=Email; DataItem='MainViewModel' (HashCode=55615518); …Run Code Online (Sandbox Code Playgroud) 概述:
我正在编写FetchXML查询以返回Dynamics 2015在线CRM实例中具有已禁用邮箱的用户.现在我来到一个需要将查询结果绑定到ListView的阶段.(该项目使用Dynamics SDK 2015库.)
为了做到这一点,我试图将返回的结果(即EntityCollection - >)转换为列表.但是CRMSDKTypeProxy在我的演员代码中找不到.
我正在按照这个例子的第二个答案进行演员:
将实体集转换为Ilist,其中Entity Collection未实现IEnumerable
题:
有谁知道如何引用CRMSDKTypeProxy?或者将我的收藏品投射到列表的任何替代方法?
代码:(简短示例)
if (ctrl.CrmConnectionMgr != null && ctrl.CrmConnectionMgr.CrmSvc != null && ctrl.CrmConnectionMgr.CrmSvc.IsReady)
{
CrmServiceClient svcClient = ctrl.CrmConnectionMgr.CrmSvc;
if (svcClient.IsReady)
{
// Get data from CRM .
string DisabledMailBoxUsersFetchXML =
@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='systemuser'>
<attribute name='fullname' />
<attribute name='businessunitid' />
<attribute name='title' />
<attribute name='address1_telephone1' />
<attribute name='positionid' />
<attribute name='systemuserid' />
<order attribute='fullname' descending='false' />
<link-entity name='mailbox' from='mailboxid' to='defaultmailbox' alias='aa'>
<filter …Run Code Online (Sandbox Code Playgroud) 我试图修改我的主要活动以转换为滚动视图但是当我在布局xml周围添加Scrollview元素时,格式化混乱了.
任何人都可以找到我在ScrollView中包装它时出错的地方吗?
这是添加Scrollview之前的布局:

这是在:

这就是我在布局xml中实现它的方式:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/ductDepth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/calc"
android:layout_centerHorizontal="true"
android:layout_marginBottom="37dp"
android:ems="10"
android:hint="Enter duct depth mm"
android:inputType="numberDecimal"
android:singleLine="true" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/offDepth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView3"
android:layout_alignLeft="@+id/ductDepth"
android:layout_marginBottom="14dp"
android:ems="10"
android:hint="Enter offset depth mm"
android:inputType="numberDecimal"
android:singleLine="true" />
<EditText
android:id="@+id/offLength"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_alignLeft="@+id/offDepth"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint="Enter offset length mm"
android:inputType="numberDecimal"
android:singleLine="true" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/offDepth"
android:layout_alignLeft="@+id/offDepth"
android:text="Depth:"
android:textSize="30sp" />
<TextView …Run Code Online (Sandbox Code Playgroud) 在这个程序中,我打印一个从计算类型double到屏幕的值.但是目前计算给出了14个小数位.我的问题是,Java中是否有一个工具来包装输出语句,可以指定数量小数位?例如round(mark1,2)

目前它的印刷方式是这样的:
double markOne = intent.getDoubleExtra("number1", 0);
result1.setText(String.valueOf(markOne)+"mm");
Run Code Online (Sandbox Code Playgroud)
是否可以setText用Java方法包装或者我必须创建自定义格式?有人能用我的代码给我一个例子吗?谢谢
我有一个很长的li元素列表超过30项.当我在ul menu下拉列表中显示它时,列表垂直向下延伸,这需要向下滚动浏览器窗口以查看每个列表元素.
我想要做的是对列表中的每一行进行分组,以在ul菜单中显示3个li元素而不是每行一个元素.
我所做的尝试是将.sub-menu li菜单使用的样式设置display: inline 为此处建议的内容,以显示li元素内联,但这对水平排序没有任何影响.
所以不是这样的:
它将显示如下(其中列表中的每个三个li元素水平分组):
简约翰杰瑞德
吉姆詹姆斯琼斯
题:
如何在n li元素的水平分组中显示列表?
在我目前的设置中,我使用此CSS作为菜单:
nav li:hover .sub-menu {
z-index: 2;
opacity: 1;
min-width: 100px;
}
.sub-menu {
width: 100%;
padding: 0px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
overflow: hidden;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0,0,0,0.2);
background: #425563;
text-align: center;
display: …Run Code Online (Sandbox Code Playgroud) 我正在读回一个可空的DateTime?属性,然后以短日期格式将该值分配给字符串属性.
我可以将日期时间值转换为短日期字符串并分配给IT_Date_String属性.但是""如果IT_Date为null,我不确定如何为字符串赋值.
你如何转换日期时间?datetime时为string.empty的值?一片空白?
这是linq中的赋值:
var status_list = query_all.ToList().Select(r => new RelStatus
{
IT_Date_String = r.IT_Date.Value.ToString("yyyy-MM-dd") != null ? r.IT_Date.Value : null
}).ToList();
Run Code Online (Sandbox Code Playgroud)
以及模型中的属性:
public DateTime? IT_Date { get; set; }
public string IT_Date_String { get; set; }
Run Code Online (Sandbox Code Playgroud) android ×3
c# ×3
java ×2
wpf ×2
binding ×1
bitmap ×1
css ×1
datetime ×1
decimal ×1
display ×1
dynamics-crm ×1
fetchxml ×1
file ×1
formatting ×1
html-lists ×1
html5 ×1
image ×1
jackson ×1
jestjs ×1
mvvm ×1
nullable ×1
overlay ×1
properties ×1
react-native ×1
scrollview ×1
url ×1
validation ×1