How To Hide Imagebutton?
I have 1 imageButton and i want to hide that button after 5sec in oncreate method. Can anyone please help me
Solution 1:
onCreate(){
new SleepTask().execute();
}
private class SleepTask extends AsyncTask{
protected void doInBackground(){
Thread.sleep(5000);
}
protected void onPostExecute(){
yourImageButton.setVisiblity(View.INVISIBLE);
}
}Solution 2:
ImageButton inherits from View so you can always use:
imageButton.setVisibility(View.INVISIBLE);
In order to have the view disappear after x amount of time you can use a handler
Handler handler = new Handler();
handler.postDelayed( new Runnable() {
public void run(){
imageButton.setVisibility(View.INVISIBLE);
}
}, 5000);//delayed 5 secs
Ensure to call this after you are done with everything of the view and after setContentView or onViewCreated (for fragments) is called
Solution 3:
imageButton.setVisible(View.INVISIBLE); or imageButton.setVisible(View.GONE);
Post a Comment for "How To Hide Imagebutton?"