Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display dialog to allow user to select which row to add the shortcut. For
 * TV channels let the user change the channel name.
 * /*from www. ja va 2s  .c o m*/
 * @see InstallShortcutReceiver
 * 
 * @param context
 * @param name
 * @param icon
 * @param uri
 */
public static void displayShortcutsRowSelection(final Launcher context, final String name, final String icon,
        final String uri) {
    if (uri == null) {
        return;
    }
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    final boolean isChannel = uri.startsWith("tv");
    dialog.setContentView(R.layout.select_row);

    final TextView channelTextView = (TextView) dialog.findViewById(R.id.channelText);
    final EditText channelNameEditText = (EditText) dialog.findViewById(R.id.channelName);
    if (isChannel) {
        channelTextView.setVisibility(View.VISIBLE);
        channelNameEditText.setVisibility(View.VISIBLE);
        channelNameEditText.setText(name);
    }

    final TextView selectTextView = (TextView) dialog.findViewById(R.id.selectText);
    selectTextView.setText(context.getString(R.string.dialog_select_row, name));

    final Spinner spinner = (Spinner) dialog.findViewById(R.id.spinner);

    final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName);
    final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio);
    currentRadioButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // hide the row name edit field if the current row radio button
            // is selected
            nameEditText.setVisibility(View.GONE);
            spinner.setVisibility(View.VISIBLE);
        }

    });
    final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio);
    newRadioButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // show the row name edit field if the new radio button is
            // selected
            nameEditText.setVisibility(View.VISIBLE);
            nameEditText.requestFocus();
            spinner.setVisibility(View.GONE);
        }

    });

    List<String> list = new ArrayList<String>();
    final ArrayList<RowInfo> rows = RowsTable.getRows(context);
    if (rows != null) {
        for (RowInfo row : rows) {
            list.add(row.getTitle());
        }
    }
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(context, R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter);

    Button buttonYes = (Button) dialog.findViewById(R.id.buttonOk);
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String shortcutName = name;
            try {
                if (isChannel) {
                    String channelName = channelNameEditText.getText().toString().trim();
                    if (channelName.length() == 0) {
                        channelNameEditText.requestFocus();
                        displayAlert(context, context.getString(R.string.dialog_channel_name_alert));
                        return;
                    }
                    shortcutName = channelName;
                }
                // if the new row radio button is selected, the user must
                // enter a name for the new row
                String rowName = nameEditText.getText().toString().trim();
                if (newRadioButton.isChecked() && rowName.length() == 0) {
                    nameEditText.requestFocus();
                    displayAlert(context, context.getString(R.string.dialog_new_row_name_alert));
                    return;
                }
                boolean currentRow = !newRadioButton.isChecked();
                int rowId = 0;
                int rowPosition = 0;
                if (currentRow) {
                    if (rows != null) {
                        String selectedRow = (String) spinner.getSelectedItem();
                        for (RowInfo row : rows) {
                            if (row.getTitle().equals(selectedRow)) {
                                rowId = row.getId();
                                ArrayList<ItemInfo> items = ItemsTable.getItems(context, rowId);
                                rowPosition = items.size(); // in last
                                // position
                                // for selected
                                // row
                                break;
                            }
                        }
                    }
                } else {
                    rowId = (int) RowsTable.insertRow(context, rowName, 0, RowInfo.FAVORITE_TYPE);
                    rowPosition = 0;
                }

                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(uri));
                ItemsTable.insertItem(context, rowId, rowPosition, shortcutName, intent, icon,
                        DatabaseHelper.SHORTCUT_TYPE);
                Toast.makeText(context, context.getString(R.string.shortcut_installed, shortcutName),
                        Toast.LENGTH_SHORT).show();
                context.reloadAllGalleries();

                if (currentRow) {
                    Analytics.logEvent(Analytics.ADD_SHORTCUT);
                } else {
                    Analytics.logEvent(Analytics.ADD_SHORTCUT_WITH_ROW);
                }

            } catch (Exception e) {
                Log.d(LOG_TAG, "onClick", e);
            }

            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.buttonCancel);
    buttonNo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_ADD_SHORTCUT);
}

From source file:com.example.google.playservices.placepicker.PlacePickerFragment.java

@Override
public void onCardClick(int cardActionId, String cardTag) {
    if (cardActionId == ACTION_PICK_PLACE) {
        // BEGIN_INCLUDE(intent)
        /* Use the PlacePicker Builder to construct an Intent.
        Note: This sample demonstrates a basic use case.
        The PlacePicker Builder supports additional properties such as search bounds.
         *//*from  ww w .ja  v a2 s .c o m*/
        try {
            PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
            Intent intent = intentBuilder.build(getActivity());
            // Start the Intent by requesting a result, identified by a request code.
            startActivityForResult(intent, REQUEST_PLACE_PICKER);

            // Hide the pick option in the UI to prevent users from starting the picker
            // multiple times.
            showPickAction(false);

        } catch (GooglePlayServicesRepairableException e) {
            GooglePlayServicesUtil.getErrorDialog(e.getConnectionStatusCode(), getActivity(), 0);
        } catch (GooglePlayServicesNotAvailableException e) {
            Toast.makeText(getActivity(), "Google Play Services is not available.", Toast.LENGTH_LONG).show();
        }

        // END_INCLUDE(intent)
    } else if (cardActionId == ACTION_REPORT_WAIT) {
        final Dialog dialog = new Dialog(this.getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.report);

        final NumberPicker np = (NumberPicker) dialog.findViewById(R.id.numpicker);
        np.setMaxValue(120);
        np.setMinValue(0);

        // Report
        Button dialogButtonReport = (Button) dialog.findViewById(R.id.dialogButtonReport);
        dialogButtonReport.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                HttpPost httppost = new HttpPost("http://powergrid.xyz/quickq/restaurantpost.php");
                httppost.setHeader("Content-type", "application/x-www-form-urlencoded");
                List<NameValuePair> nameValuePairs = new ArrayList<>(2);
                // TODO
                nameValuePairs.add(new BasicNameValuePair("placeid", globalplace.getId()));
                nameValuePairs.add(new BasicNameValuePair("waittime", String.valueOf(np.getValue())));
                try {
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                } catch (UnsupportedEncodingException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                powergridServerReportTime task = new powergridServerReportTime();
                task.execute(httppost);

                dialog.dismiss();
            }
        });

        // Cancel
        Button dialogButtonCancel = (Button) dialog.findViewById(R.id.dialogButtonCancel);
        // If button is clicked, close the custom dialog
        dialogButtonCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }
}

From source file:edu.berkeley.boinc.BOINCActivity.java

/**
 * React to selection of nav bar item// w w  w. j  av a2s  .  co m
 * @param item
 * @param position
 * @param init
 */
private void dispatchNavBarOnClick(NavDrawerItem item, boolean init) {
    // update the main content by replacing fragments
    if (item == null) {
        if (Logging.WARNING)
            Log.w(Logging.TAG, "dispatchNavBarOnClick returns, item null.");
        return;
    }
    if (Logging.DEBUG)
        Log.d(Logging.TAG, "dispatchNavBarOnClick for item with id: " + item.getId() + " title: "
                + item.getTitle() + " is project? " + item.isProjectItem());

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Boolean fragmentChanges = false;
    if (init) {
        // if init, setup status fragment
        ft.replace(R.id.status_container, new StatusFragment());
    }
    if (!item.isProjectItem()) {
        switch (item.getId()) {
        case R.string.tab_tasks:
            ft.replace(R.id.frame_container, new TasksFragment());
            fragmentChanges = true;
            break;
        case R.string.tab_notices:
            ft.replace(R.id.frame_container, new NoticesFragment());
            fragmentChanges = true;
            break;
        case R.string.tab_projects:
            ft.replace(R.id.frame_container, new ProjectsFragment());
            fragmentChanges = true;
            break;
        case R.string.menu_help:
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://boinc.berkeley.edu/wiki/BOINC_Help"));
            startActivity(i);
            break;
        case R.string.menu_about:
            final Dialog dialog = new Dialog(this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_about);
            Button returnB = (Button) dialog.findViewById(R.id.returnB);
            TextView tvVersion = (TextView) dialog.findViewById(R.id.version);
            try {
                tvVersion.setText(getString(R.string.about_version) + " "
                        + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
            } catch (NameNotFoundException e) {
                if (Logging.WARNING)
                    Log.w(Logging.TAG, "version name not found.");
            }

            returnB.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();
            break;
        case R.string.menu_eventlog:
            startActivity(new Intent(this, EventLogActivity.class));
            break;
        case R.string.projects_add:
            startActivity(new Intent(this, SelectionListActivity.class));
            break;
        case R.string.tab_preferences:
            ft.replace(R.id.frame_container, new PrefsFragment());
            fragmentChanges = true;
            break;

        default:
            if (Logging.ERROR)
                Log.d(Logging.TAG,
                        "dispatchNavBarOnClick() could not find corresponding fragment for " + item.getTitle());
            break;
        }

    } else {
        // ProjectDetailsFragment. Data shown based on given master URL
        Bundle args = new Bundle();
        args.putString("url", item.getProjectMasterUrl());
        Fragment frag = new ProjectDetailsFragment();
        frag.setArguments(args);
        ft.replace(R.id.frame_container, frag);
        fragmentChanges = true;
    }

    mDrawerLayout.closeDrawer(mDrawerList);

    if (fragmentChanges) {
        ft.commit();
        setTitle(item.getTitle());
        mDrawerListAdapter.selectedMenuId = item.getId(); //highlight item persistently
        mDrawerListAdapter.notifyDataSetChanged(); // force redraw
    }

    if (Logging.DEBUG)
        Log.d(Logging.TAG, "displayFragmentForNavDrawer() " + item.getTitle());
}

From source file:de.mrapp.android.dialog.AbstractMaterialDialogFragment.java

@NonNull
@Override/*from w w w  .  j  a va  2s .c  om*/
public final Dialog onCreateDialog(final Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getContext(), themeResourceId);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

From source file:com.gunz.carrental.Fragments.CarsFragment.java

private void addCar(final boolean isAddCar, final int position) {
    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.custom_dialog_car);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);/*  ww  w. j a v a 2  s. c o  m*/
    TextView lblTitle = (TextView) dialog.findViewById(R.id.lblTitle);
    final MaterialEditText txBrand = (MaterialEditText) dialog.findViewById(R.id.txBrand);
    final MaterialEditText txModel = (MaterialEditText) dialog.findViewById(R.id.txModel);
    final MaterialEditText txLicense = (MaterialEditText) dialog.findViewById(R.id.txLicense);
    final MaterialEditText txFare = (MaterialEditText) dialog.findViewById(R.id.txFare);
    Button btnSave = (Button) dialog.findViewById(R.id.btnSave);
    ImageView imgClose = (ImageView) dialog.findViewById(R.id.imgClose);
    dialog.show();
    clearErrorMsg(dialog);

    if (!isAddCar) {
        lblTitle.setText(getActivity().getResources().getString(R.string.update_car_title));
        txBrand.setText(cars.get(position).brand);
        txModel.setText(cars.get(position).type);
        txLicense.setText(cars.get(position).licensePlat);
        txFare.setText(String.valueOf((int) cars.get(position).farePerDay));
    } else {
        lblTitle.setText(getActivity().getResources().getString(R.string.add_new_car_title));
    }

    btnSave.setOnClickListener(new OnOneClickListener() {
        @Override
        public void onOneClick(View v) {
            if (TextUtils.isEmpty(txBrand.getText().toString().trim())) {
                txBrand.setText("");
                txBrand.setError(getActivity().getResources().getString(R.string.validation_required));
                txBrand.requestFocus();
            } else if (TextUtils.isEmpty(txModel.getText().toString().trim())) {
                txModel.setText("");
                txModel.setError(getActivity().getResources().getString(R.string.validation_required));
                txModel.requestFocus();
            } else if (TextUtils.isEmpty(txLicense.getText().toString().trim())) {
                txLicense.setText("");
                txLicense.setError(getActivity().getResources().getString(R.string.validation_required));
                txLicense.requestFocus();
            } else if (TextUtils.isEmpty(txFare.getText().toString().trim())) {
                txFare.setText("");
                txFare.setError(getActivity().getResources().getString(R.string.validation_required));
                txFare.requestFocus();
            } else {
                String confirmText;
                if (isAddCar) {
                    confirmText = getActivity().getResources().getString(R.string.dialog_add_car_question);
                } else {
                    confirmText = getActivity().getResources().getString(R.string.dialog_update_car_question);
                }
                new SweetAlertDialog(getActivity(), SweetAlertDialog.NORMAL_TYPE)
                        .setTitleText(getActivity().getResources().getString(R.string.dialog_confirmation))
                        .setContentText(confirmText)
                        .setCancelText(getActivity().getResources().getString(R.string.btn_cancel))
                        .setConfirmText(getActivity().getResources().getString(R.string.btn_save))
                        .showCancelButton(true)
                        .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sweetAlertDialog) {
                                if (isAddCar) {
                                    saveNewCar(dialog, txBrand.getText().toString().trim(),
                                            txModel.getText().toString().trim(),
                                            Integer.parseInt(txFare.getText().toString().trim()),
                                            txLicense.getText().toString().trim());
                                } else {
                                    updateCar(dialog, cars.get(position).id,
                                            txBrand.getText().toString().trim(),
                                            txModel.getText().toString().trim(),
                                            Integer.parseInt(txFare.getText().toString().trim()),
                                            txLicense.getText().toString().trim());
                                }
                                sweetAlertDialog.dismiss();
                            }
                        }).show();
            }
        }
    });

    imgClose.setOnClickListener(new OnOneClickListener() {
        @Override
        public void onOneClick(View v) {
            Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.bounce);
            animation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    dialog.dismiss();
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            v.startAnimation(animation);
        }
    });
}

From source file:com.franmontiel.fullscreendialog.FullScreenDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    initBuilderArguments();//from   ww w .j a v  a  2s .c o m

    Dialog dialog = new Dialog(getActivity(), getTheme()) {
        @Override
        public void onBackPressed() {
            onDiscardButtonClick();
        }
    };
    if (!fullScreen)
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    return dialog;
}

From source file:com.nbplus.vbroadlauncher.fragment.LoadIoTDevicesDialogFragmentStatus.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new Dialog(
            getActivity()/*new ContextThemeWrapper(getActivity(), R.style.FullScreenDialog)*/);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    setRetainInstance(true);//from   w  w w  .j  a v a2  s . c o  m
    originalOrientation = getActivity().getRequestedOrientation();
    getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    // fullscreen without statusbar
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    dialog.setCancelable(false);
    this.setCancelable(false);

    // disable back key
    dialog.setOnKeyListener(this);

    // set content view
    View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_iot_devices, null, false);
    dialog.setContentView(v);

    // grid view
    mGridView = (GridView) v.findViewById(R.id.iot_devices_grid);
    mGridView.setEmptyView(v.findViewById(android.R.id.empty));

    // set button control
    mCloseButton = (ImageButton) v.findViewById(R.id.btn_close);
    mCloseButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnClose..");
            ((BaseActivity) getActivity()).dismissProgressDialog();
            Intent sendIntent = new Intent();
            sendIntent.setAction(Constants.ACTION_IOT_DEVICE_LIST);
            sendIntent.putExtra(Constants.EXTRA_IOT_DEVICE_CANCELED, true);
            LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(sendIntent);

            dismiss();
        }
    });

    mRefreshButton = (Button) v.findViewById(R.id.btn_refresh);
    mRefreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnRefresh..");
            ((BaseActivity) getActivity()).showProgressDialog();

            IoTInterface.getInstance().getDevicesList(DeviceTypes.ALL, LoadIoTDevicesDialogFragmentStatus.this,
                    true);
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    ((BaseActivity) getActivity()).dismissProgressDialog();
                }
            }, 6000);
        }
    });

    mSendButton = (Button) v.findViewById(R.id.btn_send);
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Log.d(TAG, "onClick btnSend..");
            ((BaseActivity) getActivity()).dismissProgressDialog();
            showSyncAlertDialog();
        }
    });

    mGridView.setOnItemClickListener(this);

    return dialog;
}

From source file:no.barentswatch.fiskinfo.MapActivity.java

/**
 * /*w  ww. jav a2  s . c o  m*/
 */
public void showMapLayersDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setContentView(R.layout.dialog_select_map_layers);

    final LinearLayout mapLayerLayout = (LinearLayout) dialog.findViewById(R.id.map_layers_checkbox_layout);
    Button okButton = (Button) dialog.findViewById(R.id.dismiss_dialog_button);
    Button cancelButton = (Button) dialog.findViewById(R.id.go_to_map_button);

    for (int i = 0; i < 5; i++) {
        View mapLayerRow = getMapLayerCheckBoxRow(getContext(), Integer.toString(i));
        mapLayerLayout.addView(mapLayerRow);
    }

    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            for (int i = 0; i < mapLayerLayout.getChildCount(); i++) {
                if (((CheckBox) ((TableRow) mapLayerLayout.getChildAt(i)).getChildAt(0)).isChecked()) {
                    // TODO: Add layer to list

                }
            }
            // TODO: Implement logic for adding map layers here.            

            dialog.dismiss();
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.setTitle(R.string.choose_map_layers);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void addImage(final String imgUrl) {
    final ImageView img = new ImageView(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(15, 0, 15, 0);/*from   w  w w .  j a  va 2  s  . c o  m*/
    params.gravity = Gravity.CENTER_HORIZONTAL;
    img.setLayoutParams(params);
    img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    lay.addView(img);

    final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false).cacheInMemory(true)
            .showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565)
            .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(150).build();
    ImageLoader.getInstance().displayImage(imgUrl, img, options);

    img.setClickable(true);
    img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getActivity());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.img_dialog_layout);
            ImageLoader.getInstance().displayImage(imgUrl.split("\\?resize=")[0],
                    ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options);
            dialog.setCancelable(true);
            dialog.show();
        }
    });
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

private void addGallery(final String[] imgUrls) {
    numGalleries++;/*from w  ww.jav a2  s  .c  o m*/
    if (!PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("load_imgs_pref", true)
            || numGalleries > Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity())
                    .getString("gallery_num_pref", "20")))
        return;
    HorizontalScrollView hsv = new HorizontalScrollView(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_HORIZONTAL;
    params.setMargins(10, 10, 10, 0);
    hsv.setLayoutParams(params);

    LinearLayout container = new LinearLayout(getActivity());
    container.setOrientation(LinearLayout.HORIZONTAL);
    for (int i = 0; i < imgUrls.length; i++) {
        final ImageView img = new ImageView(getActivity());
        LayoutParams imgPar = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        if (i == 0)
            imgPar.setMargins(5, 10, 0, 10);
        else
            imgPar.setMargins(10, 10, 0, 10);
        img.setLayoutParams(imgPar);
        img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        container.addView(img);

        final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false)
                .cacheInMemory(true).showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565)
                .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(200).build();
        ImageLoader.getInstance().displayImage(imgUrls[i], img, options);

        final int k = i;
        img.setClickable(true);
        img.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(getActivity());
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.img_dialog_layout);
                ImageLoader.getInstance().displayImage(imgUrls[k].split("\\?resize=")[0],
                        ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options);
                dialog.setCancelable(true);
                dialog.show();
            }
        });
    }
    hsv.addView(container);
    lay.addView(hsv);
}