Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setView.

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.coincollection.MainActivity.java

/**
 * Finishes setting up the view once the database has been opened.
 *//* ww  w  . ja v a 2s .com*/
private void finishViewSetup() {

    // Called from the InitTask after the database has been successfully
    // opened for the first time.  Now we can be fairly sure that future
    // open's won't trigger an ANR issue.

    if (BuildConfig.DEBUG) {
        Log.v("mainActivity", "finishViewSetup");
    }

    // Instantiate the DatabaseAdapter
    mDbAdapter = new DatabaseAdapter(this);

    // Populate mCollectionListEntries with the data from the database
    updateCollectionListFromDatabase();

    // Instantiate the FrontAdapter
    mListAdapter = new FrontAdapter(mContext, mCollectionListEntries, mNumberOfCollections);

    ListView lv = (ListView) findViewById(R.id.main_activity_listview);

    lv.setAdapter(mListAdapter);

    // TODO Not sure what this does?
    lv.setTextFilterEnabled(true); // Typing narrows down the list

    // For when we use fragments, listen to the backstack so we can transition back here from
    // the fragment

    getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
        public void onBackStackChanged() {

            if (0 == getSupportFragmentManager().getBackStackEntryCount()) {

                // We are back at this activity, so restore the ActionBar
                getSupportActionBar().setTitle(mRes.getString(R.string.app_name));
                getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                getSupportActionBar().setHomeButtonEnabled(false);

                // The collections may have been re-ordered, so update them here.
                updateCollectionListFromDatabase();

                // Change it out with the new list
                mListAdapter.items = mCollectionListEntries;
                mListAdapter.numberOfCollections = mNumberOfCollections;
                mListAdapter.notifyDataSetChanged();
            }
        }
    });

    // Now set the onItemClickListener to perform a certain action based on what's clicked
    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            // See whether it was one of the special list entries (Add collection, delete
            // collection, etc.)
            if (position >= mNumberOfCollections) {

                int newPosition = position - mNumberOfCollections;
                Intent intent;

                switch (newPosition) {
                case ADD_COLLECTION:
                    intent = new Intent(mContext, CoinPageCreator.class);
                    startActivity(intent);
                    break;
                case REMOVE_COLLECTION:

                    if (mNumberOfCollections == 0) {
                        Toast.makeText(mContext, mRes.getString(R.string.no_collections), Toast.LENGTH_SHORT)
                                .show();
                        break;
                    }
                    // Thanks!
                    // http://stackoverflow.com/questions/2397106/listview-in-alertdialog
                    CharSequence[] names = new CharSequence[mNumberOfCollections];
                    for (int i = 0; i < mNumberOfCollections; i++) {
                        names[i] = mCollectionListEntries.get(i).getName();
                    }

                    AlertDialog.Builder delete_builder = new AlertDialog.Builder(mContext);
                    delete_builder.setTitle(mRes.getString(R.string.select_collection_delete));
                    delete_builder.setItems(names, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int item) {
                            showDeleteConfirmation(mCollectionListEntries.get(item).getName());
                        }
                    });
                    AlertDialog alert = delete_builder.create();
                    alert.show();
                    break;
                case IMPORT_COLLECTIONS:
                    handleImportCollectionsPart1();
                    break;
                case EXPORT_COLLECTIONS:
                    handleExportCollectionsPart1();
                    break;
                case REORDER_COLLECTIONS:

                    if (mNumberOfCollections == 0) {
                        Toast.makeText(mContext, mRes.getString(R.string.no_collections), Toast.LENGTH_SHORT)
                                .show();
                        break;
                    }

                    // Get a list that excludes the spacers
                    List<CollectionListInfo> tmp = mCollectionListEntries.subList(0, mNumberOfCollections);
                    ArrayList<CollectionListInfo> collections = new ArrayList<>(tmp);

                    ReorderCollections fragment = new ReorderCollections();
                    fragment.setCollectionList(collections);

                    // Show the fragment used for reordering collections
                    getSupportFragmentManager().beginTransaction()
                            .add(R.id.main_activity_frame, fragment, "ReorderFragment").addToBackStack(null)
                            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();

                    // Setup the actionbar for the reorder page
                    // TODO Check for NULL
                    getSupportActionBar().setTitle(mRes.getString(R.string.reorder_collection));
                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                    getSupportActionBar().setHomeButtonEnabled(true);

                    break;
                case ABOUT:

                    LayoutInflater inflater = (LayoutInflater) mContext
                            .getSystemService(LAYOUT_INFLATER_SERVICE);
                    View layout = inflater.inflate(R.layout.info_popup,
                            (ViewGroup) findViewById(R.id.info_layout_root));

                    AlertDialog.Builder info_builder = new AlertDialog.Builder(mContext);
                    info_builder.setView(layout);

                    TextView tv = (TextView) layout.findViewById(R.id.info_textview);
                    tv.setText(buildInfoText());

                    AlertDialog alertDialog = info_builder.create();
                    alertDialog.show();
                    break;
                }

                return;
            }
            // If it gets here, the user has selected a collection

            Intent intent = new Intent(mContext, CollectionPage.class);

            CollectionListInfo listEntry = mCollectionListEntries.get(position);

            intent.putExtra(CollectionPage.COLLECTION_NAME, listEntry.getName());
            intent.putExtra(CollectionPage.COLLECTION_TYPE_INDEX, listEntry.getCollectionTypeIndex());

            startActivity(intent);
        }
    });
}

From source file:com.hackensack.umc.activity.DependentDetailsActivity.java

private void showDilaog(String message) {

    //        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
    //            @Override
    //            public void onClick(DialogInterface dialog, int which) {
    //                switch (which) {
    //                    case DialogInterface.BUTTON_POSITIVE:
    //                        new SubmitInfoCall().execute();
    //                        dialog.dismiss();
    //                        break;
    ////from www.  j  a v a 2  s .co m
    //                    case DialogInterface.BUTTON_NEGATIVE:
    //                        dialog.dismiss();
    //                        break;
    //                }
    //            }
    //        };
    //
    //        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(DependentDetailsActivity.this);
    //        builder.setTitle("Alert");
    //        builder.setMessage(message + " .Try again.").setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener).show();

    if (!isFinishing()) {

        AlertDialog.Builder builder = new AlertDialog.Builder((getSupportActionBar().getThemedContext()));

        LayoutInflater inflater = getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.dialog_network_offline, null);
        builder.setView(dialogView);

        ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Alert");
        ((TextView) dialogView.findViewById(R.id.text_message)).setText(message);

        Button btnCancel = (Button) dialogView.findViewById(R.id.button_dialog_cancel);
        btnCancel.setVisibility(View.VISIBLE);
        btnCancel.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                alert.dismiss();
            }
        });

        Button btnOk = (Button) dialogView.findViewById(R.id.button_dialog_ok);
        btnOk.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {

                new SubmitInfoCall().execute();
                alert.dismiss();

            }
        });

        alert = builder.show();
    }

}

From source file:com.hackensack.umc.activity.DependentDetailsActivity.java

public void showAlert(Context context, String message, String title, final OuterQuetions outerQuetions) {

    //        new android.app.AlertDialog.Builder(context)
    //                .setTitle(title)
    //                .setMessage(message)
    //                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
    //                    public void onClick(DialogInterface dialog, int which) {
    //                        dialog.dismiss();
    //                        /*Bundle b = new Bundle();
    //                        b.putParcelable(Constant.QUETIONS_DATA, outerQuetions);
    //                        b.putString(Constant.EMAIL_ID, mEmail.getText().toString());
    //                        b.putParcelable(Constant.PATIENT_FOR_EPIC_CALL, cretepationToSendForEpicCall());*/
    ///*from   w  ww .j  a  v  a 2  s .  co m*/
    //                        Intent intent = new Intent(DependentDetailsActivity.this, QuetionsActivity.class);
    //                        intent.putExtra(Constant.QUETIONS_DATA, outerQuetions);
    //                        if (mInsuranceInfo == null) {
    //                            mInsuranceInfo = new InsuranceInfo();
    //                        }
    //                        intent.putExtra(Constant.INSURANCE_DATA_TO_SEND, new CoverageJsonCreator(mInsuranceInfo.getPlanProvider(), mInsuranceInfo.getMemberNumber(), mInsuranceInfo.getGroupNumber(), mInsuranceInfo.getSubscriberId(), mInsuranceInfo.getReference(), mInsuranceInfo.getSubscriberName(), mInsuranceInfo.getSubscriberDateOfBirth()));
    //                        intent.putExtra(Constant.EMAIL_ID, mEmail.getText().toString());
    //                        intent.putExtra(Constant.PATIENT_FOR_EPIC_CALL, createPationToSendForEpicCall());
    //                        // intent.putExtra("bundle", b);
    //                        startActivity(intent);
    //                    }
    //                })
    //                .setCancelable(false)
    //                .show();

    if (!isFinishing()) {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setCancelable(false);
        LayoutInflater inflater = getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.dialog_network_offline, null);
        builder.setView(dialogView);

        ((TextView) dialogView.findViewById(R.id.dialog_title)).setText(title);
        ((TextView) dialogView.findViewById(R.id.text_message)).setText(message);

        Button btnDismiss = (Button) dialogView.findViewById(R.id.button_dialog_ok);
        btnDismiss.setOnClickListener(new Button.OnClickListener() {

            @Override
            public void onClick(View v) {
                alert.dismiss();

                Intent intent = new Intent(DependentDetailsActivity.this, QuetionsActivity.class);
                intent.putExtra(Constant.QUETIONS_DATA, outerQuetions);
                if (mInsuranceInfo == null) {
                    mInsuranceInfo = new InsuranceInfo();
                }
                //with nwe json creator.
                intent.putExtra(Constant.INSURANCE_DATA_TO_SEND,
                        new CoverageJsonCreatorNew(mInsuranceInfo.getPlanProvider(),
                                mInsuranceInfo.getMemberNumber(), mInsuranceInfo.getGroupNumber(),
                                mInsuranceInfo.getSubscriberId(), mInsuranceInfo.getReference(),
                                mInsuranceInfo.getSubscriberName(), mInsuranceInfo.getSubscriberDateOfBirth()));
                intent.putExtra(Constant.EMAIL_ID, mEmail.getText().toString());
                intent.putExtra(Constant.PATIENT_FOR_EPIC_CALL, createPationToSendForEpicCall());
                // intent.putExtra("bundle", b);
                startActivity(intent);

            }
        });

        alert = builder.show();
    }

}

From source file:com.zertinteractive.wallpaper.MainActivity.java

public void helpDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    builder.setView(inflater.inflate(R.layout.info_dialog, null));
    AlertDialog ad = builder.create();// w  ww . ja v  a2s.co m
    ad.setTitle("Mood Wallpaper");
    ad.setButton(AlertDialog.BUTTON_NEGATIVE, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    ad.show();

    TextView noteView = (TextView) ad.findViewById(R.id.web_link);
    noteView.setText("www.somthing.com/zert");
    Linkify.addLinks(noteView, Linkify.ALL);

    TextView email = (TextView) ad.findViewById(R.id.email_zert);
    email.setText("zert@gmail.com");
    Linkify.addLinks(email, Linkify.EMAIL_ADDRESSES);

}

From source file:com.example.android.naradaoffline.DatagramFragment.java

/**
 * Set up the UI and background operations for chat.
 *//*  w ww  .j av a2 s  .c  o  m*/
private void setupChat() {
    Log.d(TAG);

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);

    //mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    //        mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events

    mGetNewsPaper.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            View view = getView();
            if (null != view) {

                //                    TextView textView = (TextView) view.findViewById(R.id.edit_text_out);
                DatagramRequest d = new DatagramRequest(DatagramRequestType.GET_NEWSPAPER,
                        mConnectedDeviceName);
                sendDatagramRequest(d);
            }
        }
    });

    // Initialize the send button with a listener that for click events
    mGetEmail.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            View view = getView();
            if (null != view) {
                //                    TextView textView = (TextView) view.findViewById(R.id.edit_text_out);

                Log.i(TAG, "button clicked");

                AlertDialog.Builder builder = new AlertDialog.Builder(DatagramFragment.this.getContext());
                builder.setTitle("Write your email here");

                LinearLayout layout = new LinearLayout(getContext());
                layout.setOrientation(LinearLayout.VERTICAL);

                // Set up the input
                final EditText email = new EditText(DatagramFragment.this.getContext());
                email.setHint("Recipient e-mail address");
                // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
                email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
                layout.addView(email);
                final EditText input = new EditText(DatagramFragment.this.getContext());
                // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
                input.setHint("Type your e-mail here");
                input.setInputType(InputType.TYPE_CLASS_TEXT);
                layout.addView(input);

                builder.setView(layout);
                // Set up the buttons
                builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        mEmail = email.getText().toString();
                        mText = input.getText().toString();
                        DatagramRequest d = new DatagramRequest(DatagramRequestType.SEND_EMAIL,
                                mConnectedDeviceName, "", mEmail, mText);
                        sendDatagramRequest(d);

                    }
                });
                builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });

                builder.show();

            }
        }
    });

    // Initialize the BluetoothDatagramService to perform bluetooth connections
    mChatService = new BluetoothDatagramService(getActivity(), mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}

From source file:com.color.kid.kidpaint.dialog.DialogAbout.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*from   w  w w  .j a v  a  2 s. co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new CustomAlertDialogBuilder(getActivity());

    builder.setTitle(R.string.about_title);
    View view = inflater.inflate(R.layout.dialog_about, null);

    TextView aboutVersionNameTextView = (TextView) view.findViewById(R.id.dialog_about_version_name_text_view);
    String versionName = PaintroidApplication.getVersionName(getActivity());
    aboutVersionNameTextView.setText(R.string.about_version);
    aboutVersionNameTextView.append(" " + versionName);

    TextView aboutTextView = (TextView) view.findViewById(R.id.about_tview_Text);
    String aboutText = String.format(getActivity().getString(R.string.about_content),
            getActivity().getString(R.string.license_type_paintroid));
    aboutTextView.setText(aboutText);

    TextView aboutUrlTextView = (TextView) view.findViewById(R.id.about_tview_Url);
    aboutUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());
    Resources resources = getActivity().getResources();
    /*String paintroidLicense = String.format(
    resources.getString(R.string.about_link_template),
    resources.getString(R.string.license_url),
    resources.getString(R.string.about_license_url_text));
    aboutUrlTextView.append(Html.fromHtml(paintroidLicense));
    aboutUrlTextView.append("\n\n");
    String aboutCatroid = String.format(
    resources.getString(R.string.about_link_template),
    resources.getString(R.string.catroid_url),
    resources.getString(R.string.about_catroid_url_text));*/
    //aboutUrlTextView.append(Html.fromHtml(aboutCatroid));
    aboutUrlTextView.append("\n");

    builder.setView(view);
    builder.setNeutralButton(R.string.done, this);

    return builder.create();

}

From source file:com.coinprism.wallet.fragment.SendTab.java

private void onConfirm(final Transaction result, final BigDecimal decimalAmount,
        final AssetDefinition selectedAsset, final String to) {
    final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this.getActivity());

    // Setting Dialog Title
    alertDialog.setTitle(getString(R.string.tab_send_dialog_confirm_transaction));

    final String assetName;
    if (selectedAsset == null)
        assetName = getString(R.string.tab_send_dialog_confirm_message_amount_bitcoin);
    else {//from   w  w w  .ja va 2 s  .c o  m
        if (selectedAsset.getName() != null && selectedAsset.getTicker() != null) {
            assetName = String.format(getString(R.string.tab_send_dialog_confirm_message_amount_known_asset),
                    selectedAsset.getTicker(), selectedAsset.getName());
        } else {
            assetName = String.format(getString(R.string.tab_send_dialog_confirm_message_amount_unknown_asset),
                    selectedAsset.getAssetId());
        }
    }

    final String message = String.format(getString(R.string.tab_send_dialog_confirm_message),
            Formatting.formatNumber(decimalAmount), assetName, to);

    final View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_confirm_send, null);
    if (!WalletState.getState().getConfiguration().isPasswordEnabled())
        dialogView.findViewById(R.id.passwordContainer).setVisibility(View.GONE);

    final TextView messageText = (TextView) dialogView.findViewById(R.id.sendSummary);
    messageText.setText(message);
    alertDialog.setView(dialogView);

    alertDialog.setPositiveButton(getString(R.string.tab_send_dialog_confirm_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    final EditText walletPasswordText = (EditText) dialogView.findViewById(R.id.walletPassword);
                    final String password = walletPasswordText.getText().toString();

                    if (!WalletState.getState().getConfiguration().isPasswordEnabled()
                            || WalletState.getState().getConfiguration().comparePassword(password))
                        onConfirmed(result);
                    else
                        showError(getString(R.string.tab_send_dialog_confirm_password_incorrect));
                }
            });

    alertDialog.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alertDialog.show();
}

From source file:com.paramonod.kikos.MainActivity.java

public void makingFullStackIcon(int id, GeoPoint geoPoint) {
    OverlayItem oi = new OverlayItem(geoPoint, main.getResources().getDrawable(id));
    final BalloonItem bi = new BalloonItem(main, oi.getGeoPoint());
    if (id != R.drawable.orpgshop) {
        bi.setOnBalloonListener(new OnBalloonListener() {
            @Override/*from w  w w .ja  v  a  2  s .  c o m*/
            public void onBalloonViewClick(BalloonItem balloonItem, View view) {
            }

            @Override
            public void onBalloonShow(BalloonItem balloonItem) {
                Intent intent = new Intent(main, DetailActivity.class);
                int m = 0;
                for (int i = 0; i < shopInterfaces.size(); i++) {
                    GeoPoint g = new GeoPoint(shopInterfaces.get(i).getCoordX(),
                            shopInterfaces.get(i).getCoordY());
                    if (g.equals(balloonItem.getGeoPoint())) {
                        m = i;
                        //  Log.e("Search", "got here" + Integer.toString(m));
                    }
                }
                intent.putExtra(DetailActivity.EXTRA_POSITION, m);
                startActivity(intent);
            }

            @Override
            public void onBalloonHide(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationStart(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationEnd(BalloonItem balloonItem) {

            }
        });
    } else {
        bi.setOnBalloonListener(new OnBalloonListener() {
            @Override
            public void onBalloonViewClick(BalloonItem balloonItem, View view) {
            }

            @Override
            public void onBalloonShow(BalloonItem balloonItem) {
                final AlertDialog.Builder b = new AlertDialog.Builder(main);
                b.setTitle(" ?");
                b.setMessage(
                        "?   ? ?  ? ? ? ?,  ");
                b.setPositiveButton("", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(main);
                        final EditText et = new EditText(main);
                        builder.setMessage(
                                "   ?,  ? ? ? ?  ??: "
                                        + searchView.getQuery());
                        builder.setTitle(" ");
                        builder.setView(et);
                        builder.setPositiveButton("", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                String s = et.getText().toString();
                                if (s.equals(""))
                                    s = searchView.getQuery().toString();
                                GeoPoint biGeo = bi.getGeoPoint();
                                Pair p = new Pair();
                                p.first = s;
                                p.second = biGeo;
                                places.add(p);
                                SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
                                String connectionsJSONString1 = new Gson().toJson(p);
                                editor.putString("places" + placesIDX, connectionsJSONString1);
                                editor.commit();
                                placesIDX++;
                            }
                        });
                        builder.show();
                    }
                });
                b.setNegativeButton("", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                b.show();
                /* mc.getDownloader().getGeoCode(new GeoCodeListener() {
                     @Override
                     public boolean onFinishGeoCode(final GeoCode geoCode) {
                         if (geoCode != null) {
                             Log.e("Not so fucking", "title" + geoCode.getTitle() + "\nsubtitle" + geoCode.getSubtitle() + "\ndisplayname" + geoCode.getDisplayName() + "\nkind" + geoCode.getKind());
                             main.name = geoCode.getTitle();
                         } else {
                         }
                         AsyncTask asyncTask = new AsyncTask() {
                             @Override
                             protected Object doInBackground(Object[] params) {
                                 String namme = "";
                                 try {
                                     URL url = new URL("https://search-maps.yandex.ru/v1/?text=" + params[0] + "&type=biz&lang=ru_RU&apikey=245e2b86-5cfb-40c3-a064-516c37dba6b2");
                        
                                     System.out.println(url);
                                     HttpURLConnection con = (HttpURLConnection) url.openConnection();
                                     con.connect();
                                     // optional default is GET
                                     con.setRequestMethod("GET");
                                     //int responseCode = con.getResponseCode(); if smth crashes
                                     BufferedReader in = new BufferedReader(
                                             new InputStreamReader(con.getInputStream()));
                                     String inputLine;
                                     String response = "";
                        
                                     while ((inputLine = in.readLine()) != null) {
                                         response += inputLine;
                                     }
                                     in.close();
                                     con.disconnect();
                                     MapActivity.jsonObject = new JSONObject(response);
                                     JSONArray ja1 = MapActivity.jsonObject.getJSONArray("features");
                                     for (int i = 0; i < ja1.length(); i++) {
                                         JSONObject j0 = ja1.getJSONObject(i);
                                         JSONObject j11 = j0.getJSONObject("properties");
                                         main.namme += " " + j11.getString("name");
                                     }
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 }
                                 return null;
                             }
                        
                             @Override
                             protected void onPostExecute(Object o) {
                                 super.onPostExecute(o);
                                 main.selectName();
                        
                        
                        
                             }
                         }.execute(main.name);
                         return true;
                     }
                 }, balloonItem.getGeoPoint());
                 intent = new Intent(main, DetailYandexActivity.class);
                */
            }

            @Override
            public void onBalloonHide(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationStart(BalloonItem balloonItem) {

            }

            @Override
            public void onBalloonAnimationEnd(BalloonItem balloonItem) {

            }
        });
    }
    bi.setDrawable(getResources().getDrawable(R.drawable.itkerk));
    oi.setBalloonItem(bi);
    o.addOverlayItem(oi);

}

From source file:com.hackensack.umc.activity.RegistrationDetailsActivity.java

private void showGenderDialog() {

    if (!isFinishing()) {

        AlertDialog.Builder builder = new AlertDialog.Builder(RegistrationDetailsActivity.this);

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

        ((TextView) dialogView.findViewById(R.id.dialog_title)).setText("Gender");

        dialogView.findViewById(R.id.progress_bar).setVisibility(View.GONE);

        ((RelativeLayout) dialogView.findViewById(R.id.relative_dialog_button)).setVisibility(View.GONE);
        mDialogListView = (ListView) dialogView.findViewById(R.id.list_specialty);
        mDialogListView.setAdapter(mGenderAdapter);

        ((ListView) dialogView.findViewById(R.id.list_specialty))
                .setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override// ww  w.  ja  v a2 s. com
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                        mGender.setText(mGenderArray[i]);
                        alert.dismiss();
                        mDialogListView = null;

                    }
                });

        alert = builder.show();
    }
}