EditText On A Popup Window

前端 未结 5 2180
抹茶落季
抹茶落季 2020-12-05 19:43

I am developing on Android 2.2 using Java. I put an editText on a PopupWindow and it\'s not working. It acts like a disabled edit text, clicking on the edit text won\'t sho

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 20:23

    call this code from any listener

    private void popUpEditText() {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Comments");
    
            final EditText input = new EditText(this);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT);
            input.setLayoutParams(lp);
            builder.setView(input);
    
            // Set up the buttons
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
    
                 // do something here on OK 
    
                }
            });
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
    
        }
    

提交回复
热议问题