欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android實(shí)現(xiàn)模擬加載中的效果

 更新時(shí)間:2016年10月28日 11:54:57   作者:xiaofeiyang  
本篇文章主要介紹的是android實(shí)現(xiàn)模擬加載中的效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。

最近閑著沒事做了一個(gè)Android小程序,具體如下:

效果圖:

原始界面

點(diǎn)擊按鈕運(yùn)行   

運(yùn)行后界面

實(shí)現(xiàn)代碼:

public class MainActivity extends AppCompatActivity {
  private Button bt;
  private TextView tv;
  public ProgressDialog myDialog;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bt=(Button)findViewById(R.id.button);
    tv=(TextView)findViewById(R.id.text);
    bt.setOnClickListener(new myOnClickListener());
  }
  private class myOnClickListener implements View.OnClickListener{
    @Override
    public void onClick(View v) {
      final CharSequence strDialogTitle=getString(R.string.app_about);
      final CharSequence strDialogBody=getString(R.string.app_msg);
      //顯示對(duì)話框
      myDialog=ProgressDialog.show(MainActivity.this,strDialogTitle,strDialogBody,true);
      tv.setText(R.string.result);
      //創(chuàng)建一個(gè)空線程模擬運(yùn)行
      new Thread(){
        public void run(){
          try{
            //設(shè)置線程睡眠3秒
            sleep(3000);
          }catch (Exception e){
            e.printStackTrace();
          }
          finally {
            //刪除所創(chuàng)建的myDialog對(duì)象
            myDialog.dismiss();
          }
        }
      }.start();//開始運(yùn)行線程
    }
  }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論