Quantcast
Channel: Android Step-by-Step
Browsing all 25 articles
Browse latest View live

How to Add a SensorEventListener

SensorEventListener was added in API Level 3Used for receiving notifications from the SensorManager when sensor values have changed.1. In the MainActivity.java file, add the lines below to the import...

View Article



How to Register a SensorEventListener

public boolean registerListener (SensorEventListener listener, Sensor sensor, int rateUs) was added in API level 3Registers a SensorEventListener for the given sensor.Note: Don't use this method with a...

View Article

How to Determine if Sensor Light Changed

Added in API Level 3Sensor.TYPE_LIGHT:values[0]: Ambient light level in SI lux units1. Register a SensorEventListener named mySensorEventListener. 2. In the method named onSensorChanged in the...

View Article

How to Set ProgressBar Progress on Light Sensor Change

API Level 3 or greater needed.1. Set the Upper Range of a ProgressBar to the Maximum Range of a Light Sensor named myProgressBar.2. Determine if Sensor Light Changed3. In the onSensorChanged method,...

View Article

Image may be NSFW.
Clik here to view.

How to Change the ProgressBar to a Horizontal Progress Bar

By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a horizontal progress bar, apply one of the styles below.1. Add a ProgressBar, in XML.2. Add the below style...

View Article


android:max - How to Set the Maximum Value for a ProgressBar, in XML

public static final int max was added in API level 1Defines the maximum value the progress can take.Must be an integer value, such as "100".By default, the progress bar is full when it reaches 100, a...

View Article

android:progress - How to Set the Default Progress Value of a ProgressBar

public static final int progress was added in API level 1Defines the default progress value, between 0 and max.Must be an integer value, such as "50".1. Add a ProgressBar, in XML2. Add the below line...

View Article

android:padding - How to Set the Padding on a ProgressBar

android:padding was added in API Level 1Sets the padding, in pixels, of all four edges. Padding is defined as space between the edges of the view and the view's content. A view size will include it's...

View Article


How to Hide/Remove ActionBar from an Activity

1. In the AndroidManifest.xml, add the below line between the activity tags.<activity android:name="MyActivity"android:theme="@android:style/Theme.NoTitleBar.Fullscreen"....> 2. Compile and...

View Article


How to Center a TextView within a RelativeLayout

android:layout_centerInParent This only works in Relativelayout View. It does not work in LinearLayout.If true, centers this child horizontally and vertically within its parent.1. In your main.xml...

View Article

How to Align an EditText to the Bottom in a View

android:layout_alignBottom was added in API Level 1Makes the bottom edge of this view match the bottom edge of the given anchor view ID. Accommodates bottom margin.1. In your main.xml file, add a...

View Article

How to Align an ImageView to the Right in a View

android:layout_alignParentRight was added in API Level 1If true, makes the right edge of this view match the right edge of the parent. Accommodates right margin.Must be a boolean value, either "true"...

View Article

How to Close an Activity

public void finish () was added in API level 1Call this when your activity is done and should be closed. The ActivityResult is propagated back to whoever launched you via onActivityResult().In this...

View Article


Image may be NSFW.
Clik here to view.

How to Add Rating Bar, in XML

RatingBar was added in API Level 1A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. The user can touch/drag or use arrow keys to set the rating when using the default...

View Article

android:id - How to Name a Rating Bar, in XML

android:id was added in API Level 1This is a unique identifier name for the RatingBar so you can refer to the RatingBar later in your project.1. Add a Rating Bar in your main.xml file.2. In the...

View Article


How to Declare a RatingBar

RatingBar was added in API Level 1A RatingBar is an extension of SeekBar and ProgressBar that shows a rating in stars. The user can touch/drag or use arrow keys to set the rating when using the default...

View Article

findViewbyID - How to Find a RatingBar using ID

findViewbyId was added in API Level 1findViewById: Look for a child RatingBar with the given id. If this view has a given id, return this RatingBar. The findViewById() method is available to all...

View Article


String.valueOf - How to Convert a Double to a String

public static String valueOf (int value) was added in API level 1Converts the specified double to its string representation.Parameters: value - the double.Returns: the double converted to a string(** I...

View Article

Image may be NSFW.
Clik here to view.

How to Set Permission for I/O Operations over NFC

public static final String NFC was added in API level 9Allows applications to perform I/O operations over NFC1. In the AndroidManifest.xml file, and add the following line Add the line between the...

View Article

Image may be NSFW.
Clik here to view.

How to Register an Activity that Responds to NFC tags for URI's that point to...

This will register an Activity that will respond only to NFC tags that correspond to a URI that points a website (URL).ACTION_NDEF_DISCOVERED(added in API level 10) is an Intent to start an activity...

View Article
Browsing all 25 articles
Browse latest View live




Latest Images