gpt4 book ai didi

java - 无法解析为变量

转载 作者:行者123 更新时间:2023-11-29 09:13:25 26 4
gpt4 key购买 nike

我有这个代码

filethemeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onNothingSelected(AdapterView<?> parent) {
}
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
int throwid = (int)id;
System.out.println( "from onItemselected" +throwid);
}
});

我尝试获取 throwid 变量的值,因此我创建了一个全局变量 themerowid 并且我这样做了:

themerowid = throwid;

但是我有这个错误:

throwid cannot be resolved to a variable

如何获取throwid值?

问题是 throwid 没有改变值,它总是返回 0 ,我认为漏洞代码:

filethemeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onNothingSelected(AdapterView<?> parent) {
}
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
throwid = (int)id;
System.out.println( "from onItemselected" +throwid);
}
});

没有被执行,这就是为什么我一直得到 0,这段代码有错误。

最佳答案

看起来 thowid 不在可见范围内。试试这个:

    filethemeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onNothingSelected(AdapterView<?> parent) {
}
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
themerowid = (int)id;
System.out.println( "from onItemselected" + id);
}
});

关于java - 无法解析为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11049593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com