我有这段代码:
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
}
}
}
答案 0 :(得分:5)
您可以尝试:
ContextNotionLevel ctnl=new ContextNotionLevel(Home.this);
答案 1 :(得分:3)
您可以使用Home.this
来引用Home对象。