Example usage for android.app AlertDialog setButton

List of usage examples for android.app AlertDialog setButton

Introduction

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

Prototype

@Deprecated
public void setButton(CharSequence text, final OnClickListener listener) 

Source Link

Document

Set a listener to be invoked when button 1 of the dialog is pressed.

Usage

From source file:com.deemsys.lmsmooc.BillingFragment.java

@SuppressWarnings("deprecation")
@Override/*  w  w w  .  j  ava 2  s  .com*/
public void onResume() {
    super.onResume();

    if (isInternetPresent) {

        // onResume();
        new Details().execute();

    }

    else {

        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();

        alertDialog.setTitle("Sorry User");

        alertDialog.setMessage("No network connection.");

        alertDialog.setIcon(R.drawable.delete);

        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {

            public void onClick(final DialogInterface dialog, final int which) {

            }
        });

        alertDialog.show();

    }

}

From source file:markson.visuals.sitapp.CCActivity.java

@SuppressWarnings("deprecation")
public void download() {
    AlertDialog alertDialog = new AlertDialog.Builder(CCActivity.this).create();
    alertDialog.setTitle(cclass);/*ww w. j a v a  2  s . c om*/
    alertDialog.setMessage("Class: " + num + "\n" + "Professor: " + instructor + "\n" + "Time: " + time + "\n"
            + "Date: " + date + "\n" + "CRN: " + crn + "\n");

    alertDialog.setButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            dialog.dismiss();

        }
    });

    alertDialog.show();

}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void button_cancelJob_noquery(AlertDialog dcancelbuilder) {
    dcancelbuilder.setButton("No", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            handlerboolean = false;/*from  w w  w .  j a  v  a 2 s  .  c  o  m*/
            handler.removeCallbacks(r);
            Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
            startActivity(openStart);

        }
    });
}

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void button_cancelJob(AlertDialog dcancelbuilder) {
    dcancelbuilder.setButton("No", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            String check = Query.jobQuery("clientcancel", job_id, 0, driver_id);
            if (check.equals("done")) {
                Intent openStart = new Intent("com.TakeTaxi.jy.TakeTaxiActivity");
                startActivity(openStart);
            } else {
                Toast.makeText(getBaseContext(), "Could not connect to server.\nPlease try again.",
                        Toast.LENGTH_SHORT).show();
            }//from  w ww .j  a v a 2s.  c om

        }
    });

}

From source file:com.bangalore.barcamp.activity.WebViewActivity.java

protected Dialog onCreateDialog(int id) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    switch (id) {
    case SHOW_ERROR_DIALOG:
        alertDialog.setCancelable(false);
        alertDialog.setTitle(getString(R.string.error_title));
        alertDialog.setMessage(getString(R.string.connection_error_and_try_again));
        alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

            @Override//from  w w w .  jav a 2s . c o m
            public void onClick(DialogInterface dialog, int which) {
                dismissDialog(SHOW_ERROR_DIALOG);
                WebViewActivity.this.finish();
            }
        });
        break;
    }
    return alertDialog;
}

From source file:com.todoroo.astrid.adapter.UpdateAdapter.java

public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView,
        final String pictureThumb, final String pictureFull, final Bitmap updateBitmap, final String message,
        final Fragment fragment, ImageCache imageCache) {
    if ((!TextUtils.isEmpty(pictureThumb) && !"null".equals(pictureThumb)) || updateBitmap != null) { //$NON-NLS-1$
        commentPictureView.setVisibility(View.VISIBLE);
        if (updateBitmap != null)
            commentPictureView.setImageBitmap(updateBitmap);
        else//from  ww  w. ja v  a 2s  .  c  o  m
            commentPictureView.setUrl(pictureThumb);

        if (pictureThumb != null && imageCache.contains(pictureThumb) && updateBitmap == null) {
            try {
                commentPictureView.setDefaultImageBitmap(imageCache.get(pictureThumb));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (updateBitmap == null) {
            commentPictureView.setUrl(pictureThumb);
        }

        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog image = new AlertDialog.Builder(fragment.getActivity()).create();
                AsyncImageView imageView = new AsyncImageView(fragment.getActivity());
                imageView
                        .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                imageView.setDefaultImageResource(android.R.drawable.ic_menu_gallery);
                if (updateBitmap != null)
                    imageView.setImageBitmap(updateBitmap);
                else
                    imageView.setUrl(pictureFull);
                image.setView(imageView);

                image.setMessage(message);
                image.setButton(fragment.getString(R.string.DLG_close), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                image.show();
            }
        });
    } else {
        commentPictureView.setVisibility(View.GONE);
    }
}

From source file:com.paranoid.lukemovement.halolauncher.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    try {//from   w ww  .j  av  a  2s .c  om
    } catch (Exception e) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Error");
        alertDialog.setMessage(
                "This app will not work on your device because your rom does not support HALO\n\nPlease install a rom that does support this feature(e.g. 'Paranoid Android')");
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
    }

    SP = getSharedPreferences(getPackageName() + "_preferences", Context.MODE_PRIVATE);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.swetha.easypark.DisplayVacantParkingLots.java

@SuppressWarnings("deprecation")
public void updatemap(ArrayList<HashMap<String, String>> alofHashmap, int Success) {

    if (success == 1) {
        try {/*ww w.  j ava 2 s.  c  o  m*/
            googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.parkinglotsmap))
                    .getMap();
            IconGenerator ig = new IconGenerator(this);

            googleMap.clear();
            for (int i = (alofHashmap.size() - 1); i >= 0; i--) {
                //canvas.drawText(alofHashmap.get(i).get("costForParking"), 0, 40, paint);
                LatLng latLng = new LatLng(Double.parseDouble(alofHashmap.get(i).get("latitude")),
                        Double.parseDouble(alofHashmap.get(i).get("longitude")));
                Bitmap bmp = ig.makeIcon(alofHashmap.get(i).get("costForParking"));
                googleMap.addMarker(new MarkerOptions().position(latLng)
                        //.title()
                        //.snippet(alofHashmap.get(i).get("lotsInfoTextView"))
                        .icon(BitmapDescriptorFactory.fromBitmap(bmp))).showInfoWindow();
                //.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_car))).showInfoWindow();
                googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
                googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
            }

            googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker arg0) {
                    LatLng markerLatLng = arg0.getPosition();
                    Log.i("DisplayVacantParkingLots",
                            "Value of the marker that was clicked is" + markerLatLng.toString());
                    for (int i = (parkingLotsMapList.size() - 1); i >= 0; i--) {
                        Log.i("DisplayVacantParkingLots", "value in the parkinglots map inside for loop"
                                + parkingLotsMapList.get(i).toString());
                        if (parkingLotsMapList.get(i).containsValue(String.valueOf(markerLatLng.latitude))
                                && parkingLotsMapList.get(i)
                                        .containsValue(String.valueOf(markerLatLng.longitude))) {
                            Intent intent = new Intent(DisplayVacantParkingLots.this,
                                    GetIndividualParkingSpotDetails.class);
                            intent.putExtra("individualParkingLotId",
                                    parkingLotsMapList.get(i).get("vacantParkingLotId"));
                            Log.i("DisplayVacantParkingLots",
                                    "The value of the parkinglot of the marker clicked is"
                                            + parkingLotsMapList.get(i).get("vacantParkingLotId"));
                            intent.putExtra(GetParkingLots.FROMTIME, DisplayVacantParkingLots.fromTime);
                            intent.putExtra(GetParkingLots.TOTIME, DisplayVacantParkingLots.toTime);
                            startActivity(intent);
                        }
                    }
                    return true;
                }

            });
        } catch (Exception e) {

        } finally {

        }
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(DisplayVacantParkingLots.this).create();

        alertDialog.setTitle("Sorry!");

        alertDialog.setMessage("No parking lots found");

        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // Write your code here to execute after dialog closed
                Intent intent = new Intent(DisplayVacantParkingLots.this, GetParkingLots.class);
                startActivity(intent);
            }
        });

        alertDialog.show();

    }
}

From source file:com.tweetlanes.android.view.ComposeBaseFragment.java

void showSimpleAlert(int stringID) {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setMessage(getString(stringID));
    alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }/* w  w  w  .j  ava 2s .c o m*/
    });
    alertDialog.show();
}

From source file:com.shafiq.mytwittle.view.ComposeBaseFragment.java

void showSimpleAlert(int stringID) {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setMessage(getString(stringID));
    alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override//from ww  w .j av a2 s  .  com
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}