Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Automatic Refresh Button
    primarykey
    data
    text
    <p>I'm having trouble with something that seems like it should be very simple. I have a frame layout with 2 Buttons (one on top of the other naturally). When I click on the top button, it automatically takes me to a website, and the button beneath it replaces it to be the visible one. I want to set up an automatic refresh so that a few seconds later, the button that was originally on top becomes on top again. Thank you for any help you can give! Here is the Java, and with my attempt at creating an automatic refresh:</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageButton bJava1= (ImageButton)findViewById(R.id.button1); final ImageButton bJava2 = (ImageButton)findViewById(R.id.button2); final WebView webview1= (WebView)this.findViewById(R.id.webView1); final MediaPlayer sound= MediaPlayer.create(Youtube.this, R.raw.soundclip1); final Handler handler = new Handler(); Refresh = new Runnable() { public void run() { bJava1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub webview1.loadUrl("http://www.google.com"); if(sound.isPlaying()){ bJava1.setVisibility(ImageButton.VISIBLE); bJava2.setVisibility(ImageButton.GONE); }else { sound.start(); bJava1.setVisibility(ImageButton.GONE); bJava2.setVisibility(ImageButton.VISIBLE); } } }); handler.postDelayed(Refresh, 10000); } }; handler.post(Refresh); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload