GithubHelp home page GithubHelp logo

android-view-helpers's Introduction

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();

android-view-helpers's People

Contributors

nesquena avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.