以下示例给出了此错误:
[DCC Error] Unit2.pas(54): E2010 Incompatible types: 'IBar' and 'Unit2.TFoo<Unit2.IBar>'
我认为问题出在Self.Create周围因为经过多次尝试编译后我不小心输入了FFoo:= TBar(Self).Create; 它编译和工作.
我正在使用Delphi XE
IFoo = interface
end;
TFoo<T: IInterface> = class(TInterfacedObject, IFoo)
private class var
FFoo: T;
public class
function Instance: T;
end;
IBar = interface(IFoo)
end;
TBar = class(TFoo<IBar>, IBar)
end;
class function TFoo<T>.Instance: T;
begin
if not Assigned(FFoo) then
begin
FFoo := Self.Create;
end;
Result := FFoo;
end;
Run Code Online (Sandbox Code Playgroud) 我希望将HashMap作为新类的每个实例的静态成员.然而,每当我尝试.get或输入我的HashMap时,我都会得到一个NullPointerException.救命!?
我正在做:public class EmailAccount {
private static HashMap<String,Integer> name_list;然后name_list.put(last_name, occurences);Even name_list.containsKey(last_name);返回NullPointer.
这来自于之前的一个问题:计算Java中字符串的出现次数
请考虑以下网址
http://m3u.com/tunein.m3u http://asxsomeurl.com/listen.asx:8024 http://www.plssomeotherurl.com/station.pls?id=111 http://22.198.133.16:8024
什么是确定文件扩展名(.m3u/.asx/.pls)的正确方法?显然,最后一个没有文件扩展名.
编辑:我忘了提到m3u/asx/pls是音频流的播放列表(文本文件),必须以不同的方式进行解析.目标确定扩展,然后将url发送到正确的解析函数.例如
url = argv[1]
ext = GetExtension(url)
if ext == "pls":
realurl = ParsePLS(url)
elif ext == "asx":
realurl = ParseASX(url)
(etc.)
else:
realurl = url
Play(realurl)
GetExtension()应该返回文件扩展名(如果有的话),最好不要连接到URL. 我花了很多时间为我正在制作的Android应用程序构建一个图标,但是无法让它在模拟器中显示应用程序.
我把它放在res/drawable-hdpi,res/drawable-mdpi,res/drawable-ldpi中各自的大小,如http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html中所定义
清单包含以下行:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
Run Code Online (Sandbox Code Playgroud)
关于它为什么没有出现的任何想法?
我正在制作一个电视指南应用程序,它使用一次ListActivity显示一个频道/一天的电视节目.我使用RelativeLayout的ListView项目,我想ListView看看是这样的:
07:00 The Breakfast Show
Latest news and topical reports
08:00 Tom and Jerry
More cat and mouse capers
Run Code Online (Sandbox Code Playgroud)
我ListView使用以下代码获取项目的数据:
Cursor cursor = db.rawQuery(SELECT blah,blah,blah);
String[] columnNames = new String[]{"start_time","title", "subtitle"};
int[] resIds = new int[]{R.id.start_time_short, R.id.title, R.id.subtitle};
adapter = new SimpleCursorAdapter(this, R.layout.guide_list_item, cursor, columnNames, resIds);
Run Code Online (Sandbox Code Playgroud)
我的问题是该start_time字段datetime具有以下格式:
2011-01-23 07:00:00
Run Code Online (Sandbox Code Playgroud)
所以我得到的是:
2011-01-23 07:00:00 The Breakfast Show
Latest news and topical reports
2011-01-23 08:00:00 Tom and Jerry
More …Run Code Online (Sandbox Code Playgroud) android android-listview simplecursoradapter android-viewbinder
我试图将Java程序转换为C#,我不知道从Java到C#的BufferedImage等效...
Java代码:
public static String ActiveContour(int x11, int x22, int y11, int y22, BufferedImage bufIm, int contor)
{
double [][] img=new double[bufIm.getHeight()][bufIm.getWidth()];
double [][] imgf=new double[bufIm.getHeight()][bufIm.getWidth()];
w=bufIm.getWidth();
h=bufIm.getHeight();
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
img[i][j]=bufIm.getRGB(j, i);
c = new Color((int)img[i][j]);
img[i][j]= 0.2898*c.getRed() + 0.5870*c.getGreen() + 0.1140*c.getBlue();
}
Run Code Online (Sandbox Code Playgroud)
我错过了一个声明吗?
using System...;
Run Code Online (Sandbox Code Playgroud)
因为在Java中我有
import java.awt.image.BufferedImage;
Run Code Online (Sandbox Code Playgroud) 嘿伙计们 - 一个简单的问题,对我来说还没有简单的答案:)
是否可以从历史对象中获取最后一页网址?我已经来过历史了.但是,这可能是未定义的,也可能不受我所见过的影响
我试图在Matlab中使用二进制数的组件作为布尔值.不幸的是,他们没有像我期望的那样行事.以下面的代码为例:
for x = dec2bin(0:1)'
x(1) % the leading bit of x
if logical(x(1))
disp('yes')
else
disp('no')
end
end
Run Code Online (Sandbox Code Playgroud)
它输出:
ans = 0
yes
ans = 1
yes
Run Code Online (Sandbox Code Playgroud)
有人知道为什么会这样,当x(1)为1时我怎么能输出'yes',否则输出'no'?
谢谢!
这个看起来很简单,但我在Ruby中计算log(Base 5)时遇到了麻烦.
显然,标准的基础10日志工作正常:
>> value = Math::log(234504)
=> 12.3652279242923
Run Code Online (Sandbox Code Playgroud)
但在我的项目中,我需要使用Base 5.根据ruby文档(http://www.ruby-doc.org/core/classes/Math.html#M001473),我似乎应该能够这样做:
Math.log(num,base)→float
>> value = Math::log(234504, 5)
ArgumentError: wrong number of arguments (2 for 1)
from (irb):203:in `log'
from (irb):203
from :0
Run Code Online (Sandbox Code Playgroud)
哪个不喜欢.任何人都知道如何在轨道上的红宝石中计算base-n中的日志?
谢谢!
在VB.NET中:
DataTable.GetChanges(Not DataRowState.Deleted)
Run Code Online (Sandbox Code Playgroud)
C#中的等价物是什么?