android 弹出框(输入框和选择框)

1、输入框:

final EditText inputServer = new EditText(this);
                inputServer.setFilters(new InputFilter[]{new InputFilter.LengthFilter(50)});
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("个性点的签名").setIcon(android.R.drawable.ic_dialog_info).setView(inputServer)
                        .setNegativeButton("取消", null);
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        String _sign = inputServer.getText().toString();
                        if(_sign!=null && !_sign.isEmpty())
                        {
                            signature_txt.setText(_sign);
                        }
                        else
                        {
                            Toast.makeText(MemberActivity.this,"签名为空",Toast.LENGTH_SHORT).show();
                        }
                    }
                });
                builder.show();

 

2、选择弹出框

final String[] items = {"保密","男","女"};
                        new AlertDialog.Builder(MemberActivity.this)
                                .setTitle("请选择")
                                .setItems(items, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog,
                                                        int which) {
                                        TextView item_value = (TextView)memberInfo_tab_list_2.getChildAt(2).findViewById(R.id.item_value);
                                        item_value.setText(items[which]);
                                    }
                                }).show();

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。