3

我有这个代码:

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
              }
    }
}
4

2 回答 2

5

你可以试试:

 ContextNotionLevel ctnl=new ContextNotionLevel(Home.this);
于 2010-02-07T22:02:38.343 回答
3

您可以使用Home.this来引用 Home 对象。

于 2010-02-07T22:01:39.297 回答