user3713134
user3713134

Reputation: 19

create Dialog with custom format on android

Is is possible to create a Dialog with custom format? I mean, not a square Dialog but one with a strange format.

Here´s a picture of what i want: http://s3.postimg.org/ha5g0d437/popup_chat.png

I want it to be a Dialog for my android app, like a popup. Is it possible to give him this strange format ou i have to work with squares?

Upvotes: 0

Views: 296

Answers (2)

rojiTOCH
rojiTOCH

Reputation: 29

You could try creating a layout design you need for example add image pop up as a background and then add the EditText layout that you need, add your layout with this code..

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder (this);

LayoutInflater inflater = this.getLayoutInflater ();
View dialogView = inflater.inflate (R.layout.YOUR_LAYOUT, null);
dialogBuilder.setView (dialogView);

EditText EditText = (EditText) dialogView.findViewById (R.id.label_field);
editText.setText ("test label");
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show ();

Upvotes: 2

A Ahmed
A Ahmed

Reputation: 1

you can create an xml file for the dialog layout in your layout folder. say you name it dialog.xml and you can add pic and buttons there. then in your main activity java:

        final Dialog myDialog = new Dialog(MainActivity.this);
        myDialog .setTitle("My fancy dialog");
        myDialog .setContentView(R.layout.dailog);
        Button meBtn = (Button) dealerDialogDialog.findViewById(R.id.newBtn);
        meBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //do something or just:
                myDialog.cancel();
            }
        });
        myDialog.show();

I hope this help you

Upvotes: 0

Related Questions