android > 页面加载中,友情提示界面

 

先是布局页面 

 

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="vertical" 
    android:orientation="vertical" >
	
    <Button 
        android:id="@+id/myButton1"
	    android:layout_width="fill_parent"
	    android:layout_height="wrap_content"
        />
        
    <TextView 
        android:id="@+id/myTextView1"
	    android:layout_width="fill_parent"
	    android:layout_height="wrap_content"      
        
        />
    
</LinearLayout>      

 

 

再 是主 activity

 

 

package sql.com;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

 

public class SqlActivity extends Activity


{
  private Button mButton1;
  private TextView mTextView1;
  public ProgressDialog myDialog = null;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    mButton1 =(Button) findViewById(R.id.myButton1);
    mTextView1 = (TextView) findViewById(R.id.myTextView1);
    mButton1.setOnClickListener(myShowProgressBar);
  }
  
  Button.OnClickListener myShowProgressBar = new Button.OnClickListener()
  {
    public void onClick(View arg0)
    {
      final CharSequence strDialogTitle = "请稍等";
      final CharSequence strDialogBody = "数据读取中 . . . .";
      
      // 显示Progress对话框
      myDialog = ProgressDialog.show
                 (
                   SqlActivity.this,
                   strDialogTitle,
                   strDialogBody, 
                   true
                 );
      
      mTextView1.setText(strDialogBody);
      
      new Thread()
      { 
        public void run()
        { 
          try
          { 
            /*在这里写上要后台运行的代码段 */
            /* 为了明显看见效果,以暂停3秒作为示范*/
            sleep(3000);
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
          finally
          {
            // 卸载所创建的myDialog对象
            myDialog.dismiss();
          }
        }
      }.start(); /* 开始运行线程 */
    } /*End: public void onClick(View arg0)*/
  };
}

 

 

from : http://blog.csdn.net/ljt127/article/details/5533662

 

 

 

自定义 字体颜色 

1, 现在  在 res/values/styles.xml  写入

 

<?xml version="1.0" encoding="UTF-8"?>
<resources>
	<style name="myDialog" parent="@android:style/Theme.Dialog">
	    <item name="android:windowBackground">@android:color/transparent</item>
	    <item name="android:textColor">#ff0000</item>
	</style> 	
</resources>

 

 

 

然后在 T3Activity.java 中

public class T3Activity extends Activity {
    /** Called when the activity is first created. */
	ProgressDialog myDialog; 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
		// 每次使用需要调用如下, 进行 new 一下 , ----
        myDialog = new ProgressDialog(T3Activity.this, R.style.myDialog);//加载style        
        myDialog.setMessage("sss");
        myDialog.show();
		// =============================================

		//OK 之后只需 dismiss();

		myDialog.dismiss();  
    }  
    
}

 

 

 

 

 

« »

发表评论

电子邮件地址不会被公开。 必填项已用*标注

昵称 *