如何在ListView上收听点击事件?
这就是我现在拥有的
ListView list = (ListView)findViewById(R.id.ListView01);
...
list.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
当我做以下
list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View childView,
int position, long id)
{
setDetail(position);
}
public void onNothingSelected(AdapterView parentView) {
}
});
Run Code Online (Sandbox Code Playgroud)
这似乎没有点击任何事情.
所有这些代码都存在于扩展Activity的类中.
我有一堆形式的代码:
someVector.push_back(Foo("some name", 1.0, 3.1415926);
someVector.push_back(Foo("different length name", 89.0, 2.717);
... 20 more entries
Run Code Online (Sandbox Code Playgroud)
我希望插入足够的空间,以便我的代码以逗号对齐,即"1.0"的逗号和"89.0"的逗号对齐 - 是否内置了这样做?
我的jpa看起来如下
public class TESTClass implements Serializable {
...
private String name;
@EmbeddedId
protected IssTESTPK issTESTPK;
@ManyToOne(optional=false)
@JoinColumns({
@JoinColumn(name="DIVISION_CODE", referencedColumnName="DIVISION_CODE", nullable=false, insertable=false, updatable=false),
@JoinColumn(name="SURVEY_NUM", referencedColumnName="SURVEY_NUM", nullable=false, insertable=false, updatable=false)})
private IssDivision issDivision;
}
Run Code Online (Sandbox Code Playgroud)
如果我更改为'name'并调用merge,它可以更新到数据库,但是当我更改issDivision并调用merge时,它不会更新数据库.怎么解决这个?
是否与之相关,因为我使用的是embededId(复合主键)?
如果我设置upadted = true,我得到以下错误
ERROR - ContextLoader.initWebApplicationContext(215) | Context initialization fa
iled
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'sessionFactory' defined in ServletContext resource [/WEB-INF/application
Context.xml]: Invocation of init method failed; nested exception is org.hibernat
e.MappingException: Repeated column in mapping for entity: com.compay.test.model
.TESTClass column: SURVEY_NUM (should …Run Code Online (Sandbox Code Playgroud) 我有一个__new__方法如下:
class MyClass(object):
def __new__(cls, *args):
new_args = []
args.sort()
prev = args.pop(0)
while args:
next = args.pop(0)
if prev.compare(next):
prev = prev.combine(next)
else:
new_args.append(prev)
prev = next
if some_check(prev):
return SomeOtherClass()
new_args.append(prev)
return super(MyClass, cls).__new__(cls, new_args)
def __init__(self, *args):
...
Run Code Online (Sandbox Code Playgroud)
但是,这会因弃用警告而失败:
DeprecationWarning: object.__new__() takes no parameters
Run Code Online (Sandbox Code Playgroud)
SomeOtherClass作为ARG游戏处理可以选择生成,这就是为什么他们正在处理中__new__,而不是在__init__
传递new_args给__init__谁的最佳方式是什么?
否则,我将不得不复制args的处理__init__(没有some_check)
我正在玩C++和pthreads,到目前为止一直很好.我可以访问一个类成员函数,如果它是静态的,我已经读过,如果我将"this"作为参数传递给pthread_create,我可以访问普通的类成员函数,因为c ++是这样做的.但我的问题是我想给该函数一个int,我不知道如何用pthread_create做多个参数.
void foo() {
struct Foo { .. };
std::vector<Foo> vec; // why is this illegal?
}
Run Code Online (Sandbox Code Playgroud)
我不会把Foo归还外面的世界.它只是我在函数中使用的临时类型.
我有一个看起来像这样的脚本
#!/bin/bash
function something() {
echo "hello world!!"
}
something | tee logfile
Run Code Online (Sandbox Code Playgroud)
我已经为这个文件设置了执行权限,当我尝试像这样运行文件时
$./script.sh
Run Code Online (Sandbox Code Playgroud)
它运行得很好,但是当我在命令行上运行它时,就像这样
$sh script.sh
Run Code Online (Sandbox Code Playgroud)
它引发了一个错误.为什么会发生这种情况,以及解决这个问题的方法是什么.
新手PowerShell问题:
我想在PowerShell中创建一个完全等同于此Bash别名的别名:
alias django-admin-jy="jython /path/to/jython-dev/dist/bin/django-admin.py"
Run Code Online (Sandbox Code Playgroud)
到目前为止,我一直在修补它,我发现这非常困难.
-PowerShell别名仅适用于PowerShell命令+函数调用
- 无法在PowerShell函数调用上允许无限数量的参数
-PowerShell似乎阻止了stdout
值得注意的是,我已经尝试过这里提出的解决方案:http://huddledmasses.org/powershell-power-user-tips-bash-style-alias-command/
并且在加载PowerShell时遇到以下与语法相关的错误:
The term 'which' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spell
ing of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Dan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:9 char:27
+ $cmd = @(which <<<< $_.Content)[0]
+ CategoryInfo : ObjectNotFound: (which:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud) 我经常打开.aspx文件.
我曾经做过语言 - > j - > javascript.每当我打开aspx文件
真的很烦人
我喜欢做捷径或宏观.
但是我在Shortcut mapper上找不到这个菜单.
我怎样才能做到这一点?
没有数据成员的类的大小返回为1个字节,即使声明了隐含的"this"指针.返回的大小不应该是4个字节(在32位机器上)?我遇到过一些文章,表明"this"指针不计算用于计算对象的大小.但我无法理解这个原因.此外,如果任何成员函数声明为virtual,则类的大小现在返回为4个字节.这意味着计算vptr以计算对象的大小.为什么在计算对象大小时会考虑vptr并忽略'this'指针?