i am currently making an android
app and tried to implement an event listener on a new thread.
This is the implementation of the onCreate
method of the main activity :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main );
new Thread(new Runnable() {
public void run(){
seek_bar() ;
}
}).start();
}
and the implementation of the seek_bar
method :
public void seek_bar()
{
seek=(SeekBar)findViewById(R.id.seekBar1) ;
seek.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//do somework
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//do some work
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//do some work
}
}
) ;
}
It works but my question is what could possibly go wrong , and is it a good practice ?