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.
Download the latest jar file and drag the JAR to your "libs" folder.
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.
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:
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();
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:
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();