让用户等待执行完。?
import android.widget.PopupWindow;
//新建实例
final PopupWindow popupWindow = new PopupWindow();
//显示
popupWindow.setOutsideTouchable(false);
popupWindow.setFocusable(false);//点击区域外不会消失,点击返回会执行back事件
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.popup,null);
popupWindow.setContentView(view);
popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER,0,0);
//消失
popupWindow.dismiss();
?popup.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:clickable="false"
android:longClickable="false" />
</RelativeLayout>
?
另外常用?
//用户选择对话框
new AlertDialog.Builder(this)
.setTitle("提示")
.setMessage("是否人为结束,重新开始?")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//点确定要执行的内容
}
})
.setNegativeButton("取消", null).show();
|