提示框
Toast.makeText(
this,提示内容,Toast.LENGTH_LENGTH).show();
对话框
警告框(AlertDailog)
Dialog ad =
new AlertDialog.Builder(Day08.this).create();
setTitle(); //设置标题
setMessage();//设置提示信息
setIcon(); //设置图片
进度处理对话框(ProgressDialog)
示例代码:
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MyLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/mybut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查找网络连接" />
</LinearLayout>
main.java
package come.waas;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class but extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.but);
Button bt12 = (Button)findViewById(R.id.btc);//取得组件
bt12.setOnClickListener(new OnClickListener() {//设置单机事件
public void onClick(View v) {
// TODO 自动生成的方法存根
final ProgressDialog proDia=ProgressDialog.show(but.this,
"搜寻网络",
"请耐心等待...");
new Thread(){
public void run(){
try{
Thread.sleep(3000);//运行3秒后关闭对话框
}catch(Exception e){
}finally{
proDia.dismiss();//关闭对话框
}
}
}.start();//线程启动
proDia.show();//显示对话框
}
});
}
}