我用过PopupWindow.使用此PopupWindow,我将BackgroundDrawable设置为空的BitmapDrawable.
当我使用以下代码时,它会给出一个弃用的警告:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable());
Run Code Online (Sandbox Code Playgroud)
所以我改成了:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable(
getApplicationContext().getResources(),
Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_8888)
));
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误,即Bitmap的宽度和高度必须大于0.
现在我使用:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable(
getApplicationContext().getResources(),
Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
));
Run Code Online (Sandbox Code Playgroud)
它有效.但是使用1x1像素的Bitmap而不是像我想要的那样完全空的Bitmap似乎有点不对.还有另一种实际使用空BitmapDrawable的方法,而不是1 x 1像素的方法吗?
我使用以下代码来获取最近7天:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd ");
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
String[] days = new String[6];
days[0] = sdf.format(date);
for(int i = 1; i < 6; i++){
cal.add(Calendar.DAY_OF_MONTH, -1);
date = cal.getTime();
days[i] = sdf.format(date);
}
for(String x: days){
System.out.println(x);
}
Run Code Online (Sandbox Code Playgroud)
这是给出以下输出:
2016-04-14
2016-04-13
2016-04-12
2016-04-11
2016-04-10
2016-04-09
Run Code Online (Sandbox Code Playgroud)
但我想要这个:
2016-04-09
2016-04-10
2016-04-11
2016-04-12
2016-04-13
2016-04-14
Run Code Online (Sandbox Code Playgroud)
如果我在代码下面使用以下行,它将给我正确的顺序:
List<String> list = Arrays.asList(days);
Collections.reverse(list);
days = (String[]) list.toArray();
for(String x: days){
System.out.println(x);
}
Run Code Online (Sandbox Code Playgroud)
但有没有其他方法可以一次性按升序排列过去7天?
public class Test
{
static int i = 1;
static void m1()
{
}
}
class Test1 extends Test
{
int i = 1; //allowed
void m1() // not allowed; Both are instance level, so why this difference? Both can be accessed with super keyword
{
}
}
Run Code Online (Sandbox Code Playgroud)
为什么静态方法不能用相同的签名隐藏,但允许静态字段执行此操作?两者都是实例级别,那么为什么只允许静态字段?
我知道我可以为所有查询设置DbContext的CommandTimeout,如下所示:
public class YourContext : DbContext
{
public YourContext() : base("YourConnectionString")
{
// Get the ObjectContext related to this DbContext
var objectContext = (this as IObjectContextAdapter).ObjectContext;
// Sets the command timeout for all the commands
// to 2 min instead of the default 30 sec
objectContext.CommandTimeout = 120;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我希望保持默认的30秒,除了一个需要更长时间的方法.
我应该如何更改此单个查询?
我确实试过用:
public void doSomething(){
// The using had another reason, but in this case it also
// automatically disposes of the DbContext
using(IMyDbContext = delegateDbContext()){
((IObjectContextAdapter)usingDb).ObjectContext.CommandTimeout = 120; …Run Code Online (Sandbox Code Playgroud) 在我们的项目中,我们保存了窗口大小,位置和最小化/最大化设置,因此我们可以在重新打开窗口时以完全相同的点和大小打开窗口.所有这一切都运行得很好,使用Window-Behavior本文底部的-class.
但问题是,当我们使用Win-button +箭头时; 这会将屏幕与屏幕一侧对齐,但这并未正确保存在行为中.相反,它在我使用Win +箭头对齐之前保存了屏幕的位置和大小,这就是它再次打开的位置.
我试图使用Window的Left,Top,ActualWidth并ActualHeight在SaveWindowState-方法(注:AssociatedObject在这个方法中的窗口.)但是,Left和Top似乎由约20-40像素被关闭,并保存右键和左键使用的ActualWidth,ActualHeight和当前的屏幕宽度/高度(使用多个显示器时)也有点痛苦.
那么,当用户使用Win +箭头对齐Window然后关闭它时,有没有办法在窗口设置中保存正确的位置和大小?
WindowSettingsBehavior:
using System;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Interop;
namespace NatWa.MidOffice.Behaviors
{
/// <summary>
/// Persists a Window's Size, Location and WindowState to UserScopeSettings
/// </summary>
public class WindowSettingsBehavior : Behavior<Window>
{
[DllImport("user32.dll")]
static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref Windowplacement …Run Code Online (Sandbox Code Playgroud) 实际的java代码是:
((rrd == null || !rrd)
&& null != dam
&& null != dam.getac()
&& null != dam.getac().getc()
&& null != sname
&& sname.equalsIgnoreCase(dam.getac().getc()))
Run Code Online (Sandbox Code Playgroud)
但是当我查看类文件时,它是:
((rrd != null) && (rrd.booleanValue()))
|| ((((null == dam)
|| (null == dam.getac())
|| (null == dam.getac().getc())
|| (null == sname)
|| (!(sname.equalsIgnoreCase(dam.getac().getc()))))))
Run Code Online (Sandbox Code Playgroud)
所有||和&&互换.
有谁能解释为什么?
我正在为iOS制作VoIP应用程序.对于来电,我设置了一些自定义铃声.它工作正常,但我想检查设备设置是否设置为振动模式或不是以编程方式.
我在网上搜索过这个问题,但我只找到了静音模式检测的答案.相反,我想检查设备是否处于振动模式.
当来电来到我的应用程序时,如果设备设置设置为振动模式,我想使用振动模式.
任何人都可以帮助我吗?
上周我们的项目从 Angular 15 更新到了 Angular 16。我们之前使用 jest-preset-Angular 的 Jest 配置现在使用内置的实验性 Jest 支持。
我们做了两个相关的改变:
我们已将以下内容添加到我们的angular.json:
"test": {
"builder": "@angular-devkit/build-angular:jest",
"options": {
"tsConfig": "tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
}
}
Run Code Online (Sandbox Code Playgroud)
"test": "jest --silent""test": "ng test"在我们的 package.json 脚本中更改为。
ng test当我们使用或一次运行所有单元测试时npm test,一切都会按预期进行。
然而,当我们尝试在 IntelliJ 中运行单独的测试时,它会给出不相关的错误。我很确定这是因为它仍然尝试运行单元测试而jest不是@angular-devkit/build-angular:jest.
当我查看 Jest 单元测试的运行配置时,我看到 Jest 包的以下内容:...\node_modules\jest。
我怎样才能将其更改为使用的 Jest @angular-devkit/build-angular?或者我还应该更改其他内容,以便使用新的 Angular 16 实验性 Jest 支持在 IntelliJ 中运行单独的 Jest 单元测试?
更新:我在第一条评论中尝试了@Oksana的建议更改:
jest更改为我们的jest:run在线 …我试图谷歌如何在画布上拖放UIElements,但找不到任何我正在寻找的东西.
我有一个带有Window的C#WPF应用程序.在窗口内我有一个Canvas,我可以在其中添加图像.我想要的是能够拖放图像,同时保持在画布的边界内.我也希望它在代码中,所以不在xaml中.
我在我添加/更新图像到画布的功能中得到了这个.TODO应该替换为拖放事件.
Image img = ImageList[i].Image;
img.Name = "Image" + i;
// TODO: Drag and Drop event for Image
// TODO: Check if Left and Top are within Canvas (minus width / height of Image)
Canvas.SetLeft(img, Left); // Default Left when adding the image = 0
Canvas.SetTop(img, Top); // Default Top when adding the image = 0
MyCanvas.Children.Add(img);
OnPropertyChanged("MyCanvas");
Run Code Online (Sandbox Code Playgroud)
PS:虽然这是为了以后,如果有人有代码一次拖放多个图像作为额外的奖金,我会很感激.
在此先感谢您的帮助.
假设我有以下模型类:
public class Product
{
private int ProductId;
private String Name;
public Product(){
setProductId(0);
setName("");
}
// Getter and Setter for the Product-ID
public void setProductId(int i){
if(i >= 0) {
ProductId = i;
} else {
ProductId = 0;
}
}
public int getProductId(){
return ProductId;
}
// Getter and Setter for the Name
public void setName(String n){
if(n != null && n.length() > 0) {
name = n;
} else {
name = "";
}
}
public String …Run Code Online (Sandbox Code Playgroud) java ×4
c# ×3
android ×2
wpf ×2
angular ×1
asp.net-mvc ×1
bitmap ×1
canvas ×1
converters ×1
date ×1
deprecated ×1
draggable ×1
gson ×1
inheritance ×1
ios ×1
jestjs ×1
json ×1
mocking ×1
objective-c ×1
unit-testing ×1
warnings ×1
window ×1
windowstate ×1