弹出框列表

//自定义弹出框对话框

 LayoutInflater factory = LayoutInflater.from(QuZheng2Activity.this);
                // 把布局文件中的控件定义在View中
                final View textEntryView = factory.inflate(R.layout.item_tianjiatiaomu, null);
                new AlertDialog.Builder(QuZheng2Activity.this)
                        // 对话框的标题
                        .setTitle("自定义添加条目")
                        // 设定显示的View
                        .setView(textEntryView)
                        // 对话框中的“完成”按钮的点击事件
                        .setPositiveButton("完成", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                EditText etname1 = (EditText) textEntryView.findViewById(R.id.etname1);
                                EditText etname2 = (EditText) textEntryView.findViewById(R.id.etname2);
                                EditText etname3 = (EditText) textEntryView.findViewById(R.id.etname3);
                                EditText etname4 = (EditText) textEntryView.findViewById(R.id.etname4);
                                EditText etname5 = (EditText) textEntryView.findViewById(R.id.etname5);
                                String checkCode1 = etname1.getText().toString().trim();
                                String checkCode2 = etname2.getText().toString().trim();
                                String checkCode3 = etname3.getText().toString().trim();
                                String checkCode4 = etname4.getText().toString().trim();
                                String checkCode5 = etname5.getText().toString().trim();
                                if (TextUtils.isEmpty(etname1.getText().toString())||TextUtils.isEmpty(etname2.getText().toString())||TextUtils.isEmpty(etname3.getText().toString())||TextUtils.isEmpty(etname4.getText().toString())||TextUtils.isEmpty(etname5.getText().toString())){
                                    Toast.makeText(QuZheng2Activity.this,"不能为空",Toast.LENGTH_SHORT).show();
                                }else {
                                    compensationItem.setName(checkCode1);
                                    compensationItem.setSpec(checkCode2);
                                    compensationItem.setUnit(checkCode4);
                                    compensationItem.setQuantity(Integer.valueOf(checkCode3));
                                    compensationItem.setPrice(Integer.valueOf(checkCode5));
                                    select_recyclerViewData.add(compensationItem);
                                    Toast.makeText(QuZheng2Activity.this,compensationItem.getName()+""+compensationItem.getUnit()+""+compensationItem.getSpec()+""+compensationItem.getPrice(),Toast.LENGTH_SHORT).show();
                                    lcqdAdapter.notifyDataSetChanged();
                                }
                            }
                        })
                        // 对话框的“退出”单击事件
                        .setNegativeButton("退出", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                //不做操作,关闭对话框
                            }
                        })
                        // 设置dialog是否为模态,false表示模态,true表示非模态
                        .setCancelable(false)
                        // 对话框的创建、显示
                        .create().show();

 

/从接口中获取列表数据添加到列表中

http://image.so.com/j?q=beijing&sn=0&pn=50 

AlertDialog.Builder builder = new AlertDialog.Builder(QuZheng2Activity.this,android.R.style.Theme_Holo_Light_Dialog);
                //builder.setIcon(R.drawable.ic_launcher);
                builder.setTitle("请选择证件类型");
                //    指定下拉列表的显示数据
                ArrayList<String> stringArrayList = new ArrayList<String>();

                for (int i=0; i<zhengjianlist.size(); i++) {
                    String json_data = zhengjianlist.get(i).getName();
                    stringArrayList.add(json_data); //add to arraylist
                }
                final String [] stringArray = stringArrayList.toArray(new String[stringArrayList.size()]);
                //    设置一个下拉的列表选择项
                builder.setItems(stringArray, new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        String s = stringArray[which];
                        party_card.setText(s);
                    }
                });
                builder.show();

 

///死数据弹出框列表

   AlertDialog.Builder builder = new AlertDialog.Builder(QuZheng2Activity.this,android.R.style.Theme_Holo_Light_Dialog);
                //builder.setIcon(R.drawable.ic_launcher);
                builder.setTitle("请选择方向");
                //    指定下拉列表的显示数据
                final String[] shuzu = new String[]{"宁波-上海","上海-宁波"};

//    设置一个下拉的列表选择项
                builder.setItems(shuzu, new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {
                        String s = shuzu[which];
                        fangxiang.setText(s);
                    }
                });
                builder.show();

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值