0
我遇到了麻煩,看起來應該很簡單。我有一個框架佈局與2個按鈕(一個在另一個頂部自然)。當我點擊頂部按鈕時,它會自動將我帶到一個網站,並且它下面的按鈕會將其替換爲可見的按鈕。我想設置一個自動刷新,以便在幾秒鐘後,原本位於頂部的按鈕再次成爲頂部。感謝您給予的任何幫助!這裏是Java,並與我創造的自動刷新嘗試:Android自動刷新按鈕
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);