Dialong弹窗与PopWindow弹窗
来源:互联网 发布:安工大网络接入系统 编辑:程序博客网 时间:2024/06/03 12:27
public class MyActivity extends Activity {
//创建按钮启动弹窗的按钮
private Button mbutton,mbutton1;
private Button mbutton,mbutton1;
//PopWindow弹窗内容
private String[] array=new String[]{"张三","李四","王二","麻子"};
private String[] array=new String[]{"张三","李四","王二","麻子"};
//创建PopWindow变量
private PopupWindow popupWindow;
private PopupWindow popupWindow;
//创建Dialog变量
AlertDialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AlertDialog dialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//找到Dialog启动按钮并监听
mbutton=(Button)findViewById(R.id.button);
mbutton=(Button)findViewById(R.id.button);
mbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@Override
public void onClick(View view) {
//弹出这个对话框
showDialog(1);
}
});
showDialog(1);
}
});
//将当前对象转成 LayoutInflater对象
LayoutInflater layoutInflater=LayoutInflater.from(this);
LayoutInflater layoutInflater=LayoutInflater.from(this);
//找到 PopWindow布局XML转成View对象
View v=layoutInflater.inflate(R.layout.popwindow_item_list,null);
View v=layoutInflater.inflate(R.layout.popwindow_item_list,null);
//用ListView对象接收XML文件中的ListView
ListView listView=(ListView)v.findViewById(R.id.onetextview);
ListView listView=(ListView)v.findViewById(R.id.onetextview);
//因为只有字符,使用ArrayAdapter放入array数组的值
ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,array);
ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1,array);
//为这个listView放入这个适配器
listView.setAdapter(arrayAdapter);
listView.setAdapter(arrayAdapter);
//找到启动PopWindow的启动按钮并监听
mbutton1=(Button)findViewById(R.id.button1);
mbutton1=(Button)findViewById(R.id.button1);
//new一个PopWindow并放入v初iew值和始化弹窗大小
popupWindow=new PopupWindow(v,200,400);
mbutton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (popupWindow.isShowing()){
popupWindow.dismiss();
}else {
popupWindow.showAsDropDown(mbutton1);
}
}
});
}
protected Dialog onCreateDialog(int id) {
popupWindow=new PopupWindow(v,200,400);
mbutton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (popupWindow.isShowing()){
popupWindow.dismiss();
}else {
popupWindow.showAsDropDown(mbutton1);
}
}
});
}
protected Dialog onCreateDialog(int id) {
//判断ID
switch (id){
switch (id){
//当id是0的时候弹出这个
case 0:AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("aa");
builder.setMessage("bb");
dialog=builder.create();
return dialog;
case 0:AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("aa");
builder.setMessage("bb");
dialog=builder.create();
return dialog;
//当id是1弹出这个
case 1:MyDialog dialog1=new MyDialog(MyActivity.this);
return dialog1;
}
return null;
}
}
case 1:MyDialog dialog1=new MyDialog(MyActivity.this);
return dialog1;
}
return null;
}
}
0 0
- Dialong弹窗与PopWindow弹窗
- popwindow底部弹窗
- PopWindow自由弹窗
- popwindow实现弹窗效果
- android Dialong
- popwindow弹窗
- 弹窗popWindow
- PopWindow:基本使用与自定义PopWindow
- Popwindow与Dialog不同方式展示底部动画弹起弹窗
- DIalog与popWindow布局
- DIalog与popWindow布局
- Dialog与PopWindow
- 与popwindow相关问题
- Android_AlertDialog与PopWindow
- android的PopWindow实现下拉弹窗
- Android PopWindow 弹窗
- 弹一个底部popwindow
- Android PopWindow与GridView练习
- Quartz管理类
- DWR中取得request,session等信息
- 【引用】Java定时触发器
- 【引用】2011 程序员薪资调查报告
- 浅析gcc、arm-linux-gcc和arm-elf-gcc关系
- Dialong弹窗与PopWindow弹窗
- DES加密与解密的java实现
- 8.1.4 在 F# 中使用函数列表
- 【转载】Servlet监听器
- 64位windows安装tomcat支持jsp
- 根据日期、时间和当地经纬度计算太阳天顶角和方位角的原理
- 【转载】太阳天顶角 太阳高度角 太阳方位角
- 【转载】SQL Server dateTime类型 模糊查询
- 用mapXtreme Java开发web gis应用