I\'ve built a simple music player in Android. The view for each song contains a SeekBar, implemented like this:
public class Song extends Activity implement
I see that you have accepted @providence's answer. Just in case, you can also use the handler too! First, do the int fields.
private static final int SHOW_LOG = 1;
private static final int HIDE_LOG = 0;
Next, make a handler instance as a field.
//TODO __________[ Handler ]__________
@SuppressLint("HandlerLeak")
protected Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
// Put code here...
// Set a switch statement to toggle it on or off.
switch(msg.what)
{
case SHOW_LOG:
{
ads.setVisibility(View.VISIBLE);
break;
}
case HIDE_LOG:
{
ads.setVisibility(View.GONE);
break;
}
}
}
};
Make a method.
//TODO __________[ Callbacks ]__________
@Override
public void showHandler(boolean show)
{
handler.sendEmptyMessage(show ? SHOW_LOG : HIDE_LOG);
}
Finally, put this at onCreate()
method.
showHandler(true);