Need access to views on the OnSeekBarChangeListener (which is in an own class)

Posted by sandkasten on Stack Overflow See other posts from Stack Overflow or by sandkasten
Published on 2012-03-26T11:26:12Z Indexed on 2012/03/26 11:29 UTC
Read the original article Hit count: 152

Filed under:
|
|

first of all I hope you understand my english because I'am not a native speaker. Okay, I'am new to android development and try following: For my app I need a SeekBar, so I create a Seekbar via XML and implement an OnSeekBarChangeListener. In the compay I work for its forbidden (because of the styleguid) to create something like this:

seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() 
{
@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) 
{
    /// Do something       
}
...
});

So I need to create a own class for the OnSeekBarChangeListener. So far no problem.

public class SeekBarChangeListener extends SeekBar implements SeekBar.OnSeekBarChangeListener
{
public SeekBarChangeListener(Context context) 
{
    super(context);
}

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

public void onStartTrackingTouch(SeekBar seekBar) 
{
}

public void onStopTrackingTouch(SeekBar seekBar) 
{
/// Do something. Following Code wont work
CheckBox RemeberUsername = (CheckBox)findViewById(R.id.RemeberUsername);
/// Always gets NULL
}
}

I need a way to get access to some controls. Normaly the findViewById works fine but not in this case (what I can totaly understand, because how should the listender know about the views?). Some good hints? Or is there no oter way like the first code snippet to get the controls? Hope someone can help me out.

© Stack Overflow or respective owner

Related posts about android

Related posts about views