自定义模态提示框
来源:互联网 发布:sql字段拼接 编辑:程序博客网 时间:2024/06/06 09:57
关于Android中模态提示框的问题
因为项目最新的效果图,中提示框为模态的,先前用的Toast,虽然可以实现功能,但是提示框后面并没有模态框那样的灰色半透明蒙板,现把代码给大家参考
customer_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- @author gKF55694 自定义dialog -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:paddingRight="20dip" android:paddingLeft="20dip"
android:layout_height="wrap_content" android:id="@+id/body" >
<TextView android:id="@+id/txt_content" android:layout_width="wrap_content"
android:gravity="left"
android:layout_height="wrap_content" android:textSize="15dip" android:textColor="#FFFFFF"
/>
</LinearLayout>
以下是核心的代码
public class Activity01 extends Activity {
private int mCount = 0; // 提示框的计数
AlertDialog al = null; // 提示框
private int tempStep; // 停留秒数
public void displayInfo(String content, int step) // 在调用的时候,只需要传入提示内容,和停留时间
{
mCount = 0;
tempStep = step;
LayoutInflater inflater = LayoutInflater.from(Activity01.this);
View customerLayout = inflater.inflate(R.layout.customer_dialog, null);
customerLayout.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
TextView txtContent = (TextView) customerLayout
.findViewById(R.id.txt_content);
txtContent.setText(content);
al = new AlertDialog.Builder(Activity01.this).setIcon(0)
.setView(customerLayout).create();
new Thread() {
public void run() {
try {
while (mCount < tempStep) {
Thread.sleep(1000);
mCount++;
}
al.dismiss();
} catch (Exception ex) {
al.dismiss();
}
}
}.start();
al.show();
}
}
- 自定义模态提示框
- js自定义提示框
- 弹出自定义提示框
- 自定义提示框
- 自定义AlertDialog提示框
- Android自定义提示框
- 自定义提示框
- 自定义alert提示框
- 自定义提示框
- iOS 自定义提示框
- iOS--自定义提示框
- 自定义弹出提示框
- bootstrap自定义提示框
- 自定义提示框
- 自定义-提示框
- JQuery自定义提示框
- 自定义控制title提示框
- 【自定义AlertDialog】退出提示框
- 有关PCM和u率、a率
- IOS---UIWebview用法点滴
- libspark.swfassist的体会
- mini2440使用 J_link 配置ADS
- 位运算——判断整数a是否可被2的幂(2、4、8、16……)整除?
- 自定义模态提示框
- (emos)Ubuntu10.04 安装Xen4.1和dom0
- 2011-9-26 Xml基础知识
- 程序员技术练级攻略
- 《超级访问》多元化跨界 涉猎财经更具亲民范
- java保留两位小数4种方法
- UART的编程
- platform_get_resource函数实现细节
- 缓存算法