Android View Helpers for Dialogs and more
Clone or download
Latest commit 22a1650 Jun 22, 2013
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
libs Initial commit Jun 21, 2013
res Initial commit Jun 21, 2013
src/com/codepath/libraries/androidviewhelpers Adds SimpleProgressDialog utility Jun 22, 2013
.gitignore Add gitignore Jun 21, 2013
AndroidManifest.xml Initial commit Jun 21, 2013
README.md Add jar link Jun 22, 2013

README.md

Android View Helpers

This library is a collection of simple view helpers to make Android development easier. Right now, this library just has a few helpful classes but they will expand over time.

Installation

Download the latest jar file and drag the JAR to your "libs" folder.

SimpleAlertDialog

This is a simple way to bring up a modal alert dialog within a DialogFragment within a FragmentActivity. The dialog fragment used is the v4.support Fragment to support all Android versions.

Usage

In apps, you often may want to display an alert asking the user a question or displaying a message to the user. Creating an alert to display is easy:

class MyActivity extends FragmentActivity {
	public void showDialog() {
		SimpleAlertDialog.build(this, 
			"Sure you want to continue?", new SimpleAlertListener() {
				@Override
				public void onPositive() {
					// handle OK
				}
				
				@Override
				public void onNegative() {
					// handle cancel
				}
		}
	   ).show();
   }
}

By default, this will display the following alert:

AlertDialog

You can also adjust the alert to include no buttons, or change the button text. To display just an "Sure" button:

SimpleAlertDialog.build(this, 
	"Sure you want to continue?", "Sure", null, new SimpleAlertListener()
).show();

To display a "Yes" and "No" button:

SimpleAlertDialog.build(this, 
	"Sure you want to continue?", "Yes", "No", new SimpleAlertListener()
).show();

You can also customize the icon in the alert and other properties:

SimpleAlertDialog alert = SimpleAlertDialog.build(this, "Confirm?", new SimpleAlertListener());
alert.setAlertIcon(R.drawable.ic_some_icon);
alert.setAlertButtons("Yes", "No");
alert.show();

SimpleProgressDialog

Often in an application there might be a long running task that requires the UI to be blocked such as uploading an image. While this isn't the best UI, occassionally this can come up.

Creating an indeterminate modal progress dialog is easy:

SimpleProgressDialog dialog = SimpleProgressDialog.build(this);

By default, this will display the following alert:

ProgressDialog

You can dismiss the dialog once the task is complete with:

dialog.dismiss();

You can also adjust the progress dialog to have a custom message:

SimpleProgressDialog dialog = SimpleProgressDialog.build(this, "Uploading...");
dialog.show();