How to show a Progress Bar inside an AlertDialog Builder along with other elements without an XML?

I am trying to create an AlertDialog for a Bluetooth transfer after the transfer notification is touched in an android phone.

I am trying something like this: Out of the below, I am getting everything - icon, title and two buttons. I am sure I can add other info like From, FileName and others using cursors with the help AlertDialog.Builder properties. I just do not know to get a progress-bar in it. I do not want to use an XML.

protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setIcon(R.id.imageFile);
    alertDialogBuilder.setTitle("File Transfer");

    ProgressDialog progressDialog;
    Context mContext = null;
    progressDialog = new ProgressDialog(mContext);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

    //alertDialogBuilder.setView(progressDialog); //STUCK HERE
    //"!" icon and "File Transfer"
    //from : device name
    //File: <name>
    //Type: <type> (<size>)
    //Receiving/Sending File
    //<%> | Green progress bar
    //Hide and Stop buttons

    alertDialogBuilder.setPositiveButton("STOP", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    alertDialogBuilder.setNegativeButton("HIDE", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alertDialog = alertDialogBuilder.create();
    return alertDialog;

}

I have everything in place except I am not able to figure out how to bring a progress-bar here.

Can I getjust a progress-bar using XML layout and use as

alertDialogBuilder.setView(R.id.what-ever-xml-file) Or how to create a view for that progress-bar in he Java file itself and put a progressbar in that view and then put that view inside the dialog.

I want sth like this:

Answers


You can use Dialog and add ProgressBar on this by using

_dialog.addContentView(view, params) method.


Need Your Help

How can I enable Vista/Win 7 theming/style for a ToolTip control?

user-interface winapi windows-7 windows-vista visual-styles

In Windows Vista and Windows 7, ToolTips have a new visual style or theme, they are shiny grey metallic. How can I enable the new style for a ToolTip control?

How do I reuse a previously-opened port, using SBCL's sockets?

sockets common-lisp port sbcl

Creating a server-side socket will fail if I'm trying to use the same port I've used before. An address-in-use error occurs.