我有以下简单的 SQL 服务器代码:
set nocount on;
if OBJECT_ID('tempdb..#A') IS NOT NULL DROP TABLE #A;
set nocount on;
create table #A
( obj_id int,
obj_name varchar(50),
obj_dt datetime);
insert into #A (
obj_id,
obj_name,
obj_dt)
values
( 1
,'name'
,'2019-01-01 00:00:00'
),
( 2
,NULL
,NULL
),
( 2
,'alias'
,'2019-02-01 00:00:00'
);
set nocount on;
if OBJECT_ID('tempdb..#B') IS NOT NULL DROP TABLE #B;
set nocount on;
select
#A.obj_id
,subq.obj_name
,subq.obj_dt
into #B
from #A
join (select
obj_id,
max(obj_name) as obj_name, …Run Code Online (Sandbox Code Playgroud) 我正在制作棋盘游戏,而我正在使用10x10 GridView作为棋盘.我创建了一个扩展BaseAdapter的ImageAdapter类,它包含一个Integer数组图标(9个补丁文件),这些用于显示电路板方块的图像.图标存储在res/drawable文件夹中,为629X629,平均大小约为5 KB.
我的ImageAdapter类具有以下getView()方法,它基本上循环使用相同的视图来节省内存:
编辑 :(我已经包含了在游戏的Activity中调用的changeIcon方法)
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
}
else{
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
public void changeIcon(int x, int y, Integer icon){
int position = (9-y)*10 + x;
mThumbIds[position] = icon;
getView(position, currentView, null);
}
Run Code Online (Sandbox Code Playgroud)
我有一个名为Game的独立类,其中处理游戏的逻辑.我将这些碎片存储在Piece [] []数组中,其中Piece是我用来保存游戏数据(你猜对了)的另一个类.相关的是处理片段移动的方法move(int xFrom,int yFrom,int xTo,int …
当用户单击"保存"按钮时,会AlertDialog出现一个并要求用户输入文件名的文本.
如果用户在没有指定名称的情况下单击肯定按钮("确定"),我想显示要求他们这样做的祝酒词,并保持AlertDialog打开状态.但是吐司从不显示,对话框关闭.
这里的代码AlertDialog是:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.save_game);
alert.setMessage(R.string.request_name);
// Set an EditText view to get user input
final EditText input = new EditText(this);
input.setHint(R.string.untitled);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
if(value != null){
// Do something with value
}
else{
Toast.makeText(context, R.string.no_name_given, Toast.LENGTH_SHORT).show();
}
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show(); …Run Code Online (Sandbox Code Playgroud) 我有一个子串列表,我想从一列strings(names)中删除.我这样定义了这个列表:
STR1 = ' - cake';
STR2 = ' - pie';
STR3 = ' - eclair';
ARRAY STR_TO_REM{*} STR1 - STR3;
Run Code Online (Sandbox Code Playgroud)
我使用以下代码删除子字符串:
N=1;
DO WHILE (N <= DIM(STR_TO_REM));
STR_TO_REMOVE = TRIM(STR_TO_REM(N));
name = TRANWRD(name,STR_TO_REMOVE,'');
N = N+1;
END;
Run Code Online (Sandbox Code Playgroud)
出于某种原因,这不起作用.例如,"Joe - cake"不会转换为"Joe".作为测试,我直接尝试了代码
test = tranwrd('Joe - cake',' - cake','');
Run Code Online (Sandbox Code Playgroud)
并获得了预期的输出,表明至少基本的想法是合理的(我知道正则表达式是一种优越的方法,但我更感兴趣的是理解代码在这一点上意外行为的原因).
然而,STR_TO_REMOVE尽管打印出的变量看起来相同,但是对' - cake' 之间的平等测试失败了.我觉得我在这里缺少一些基本的东西,并且非常感谢任何帮助.
我从Pentaho 社区网站上的sourceforge 链接将 Pentaho Data Integration(或 Kettle)下载到我的 Windows 10 机器上。解压文件后,我按照社区网站上的说明启动软件,此处引用:
解压下载的文件后,您可以通过导航到文件夹 /data-integration 并双击 Spoon.bat 来启动 Spoon
我的操作系统无法识别指定文件夹中的任何 .bat 文件,但该文件夹中有一个同名的 Windows 批处理文件,并且它具有与该文件相同的大小 (4 KB) Spoon.bat,所以我相信它与说明中提到的文件相同。
打开此文件似乎在命令提示符窗口中执行批处理指令,该窗口立即消失。没有观察到其他影响;特别是,没有启动任何软件。
我用谷歌搜索,发现此类问题的一个常见原因是没有安装 64 位版本的 java。所以我从这个链接安装了一个 64 位版本的 java 运行时环境,并按照这个论坛帖子中描述的方法将java 可执行文件的链接放在 pentaho 期望的路径中。
即使在我重新启动计算机后,这也没有效果。
有没有更简单的方法来让这个软件工作,我不知道,或者我在这里错过了一个步骤?任何帮助将不胜感激!
我在onDraw自定义视图的方法中
为我的画布设置了一个矩阵,canvas.setMatrix(matrix);然后我只使用预定义的绘制绘制一个网格:
canvas.drawRect(0,0,viewWidth,viewHeight, background);
for(int i=0; i <= nRows; i++){
canvas.drawLine(0,i*cellHeight, nCols*cellWidth,i*cellHeight,lines);
canvas.drawLine(i*cellWidth, 0, i*cellWidth, nRows*cellHeight, lines);
if(i != nRows)
canvas.drawText(""+i, i*cellWidth, (i+1)*cellHeight, text);
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,整个画布偏移了一个细胞高度的1.5倍左右.知道为什么会发生这种情况或如何解决它?因此,矩阵没有初始化,因此根据文档应该是身份.
非常感谢!
我想我遗漏了一些相当简陋的东西,但在下面的代码中,我The local variable array may not have been initialized在我测试其无效性的行中得到了错误
:
int [] array;
outerloop:
for(int x = xMin;x <= xMax;x++){
for(int y = yMin;y <= yMax;y++){
if(condition(x,y)){
array = new int[2];
array[0] = x;
array[1] = y;
break outerloop;
}
}
}
if(array != null){
//do something
}
Run Code Online (Sandbox Code Playgroud)
为什么是这样?在变量未初始化的情况下,测试是否应该返回false?我已经离开Java一段时间但我不认为我已经忘记了那么多....
提前致谢 :)