gpt4 book ai didi

java - 如何在匿名类中引用更高的类

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:50 25 4
gpt4 key购买 nike

我有这个代码:

public class Home extends Activity{

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
//at some point I have
s.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {

ContextNotionLevel ctnl=new ContextNotionLevel(this);
// <-- how can I reference Home class here to replace **this**, which as it is points to OnSeekBarChangeListener
}
}
}

最佳答案

你可以试试:

 ContextNotionLevel ctnl=new ContextNotionLevel(Home.this);

关于java - 如何在匿名类中引用更高的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2218531/

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