Skip to main content

Posts

ListView - Android Tutorial

In this tutorial i will be demonstrating how to build simple android ListView . This article is about creating listview and launching new activity on selecting single list item. Now follow the coding 1. Create the project 2. Extend your MainActivity class from ListActivity 3.  Now we need a string resources file to store all list item labels. So create an XML file under values folder     and name it as list_data.xml  and paste the following code.    ( Right Click on  res/values ⇒ New ⇒ Android XML File ) list_data.xml <? xml version= "1.0" encoding= "utf-8" ?> <resources>      <string-array name= "android_versions">          <item> Cupcake </item>          <item> Donut </item>          <item> Eclair </item>         <item> Froyo </item>          <item> Gingerbread </item>         <item> Honeycomb </item>          <item> Ice Cr

How to Import file from external storage - Android Tutorial

In this example, we can see how to import the file in external location . Fetching the data from that file and show it in Log-cat as well as in List-view.   This simple example, contains one button (Click to import from SD card) to access the file data from an external location. Now follow the coding to develop this simple application     Create a New Project 1. activity_main.xml <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"      android:layout_height="match_parent"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context="com.example.readfile.MainActivit

Accelerometer Basic Example - Detect Phone Shake Motion - Android Tutorial

In this example detecting Accelerometer Motion , when Accelerometer force value cross threshold showing an alert for motion detected. Use :    1. You can use this example in games based on Accelerometer Motion (Phone Tilt).      2. You can use this example for battery consumption when using GPS Calls.     Combine Screen Wake Sleep Example with this example to consume less battery when calling GPS calls.Later We will give combined example to consume less battery. Now follow the coding to develop this simple application 1. activity_accelerometer.xml <? xml version= "1.0" encoding= "utf-8" ?>   < RelativeLayout   xmlns: android = "http://schemas.android.com/apk/res/android"   xmlns: tools = "http://schemas.android.com/tools"     android :layout_width= "match_parent"     android :layout_height= "match_parent"     android :paddingBottom= "@dimen/activ