Skip to main content

Posts

Showing posts from 2012

Displaying and Saving Image in Sdcard

Hi all. In this post i am going to discuss how to get an image from any URL and saving an image into sdcard and also capturing the whole screen. Now lets design a small layout as in the capture.     The following xml named  first_activity.xml   is used to design the capture. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/layoutCapture" >     <Button         android:id="@+id/showImage"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"         android:layout_alignParentTop="true"         android:layout_marginLeft="15dp"         android:layout_marginTop="25dp"

Image Slide Show

Hi everyone. In this tutorial i am going to show you all the code which when run will display the images as a slideshow. Below is the attached screen shot :  For this i am considering the images from the Sdcard's images folder where i am having all the images. Next to display the images i am using View Flipper concept. I am adding ImageViews to the viewflipper so that the images can be displayed onto the screen. Now lets start  Design an xml layout as below (say 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" >     <ViewFlipper         android:id="@+id/main_flipper"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"  

SQLite Database

This tutorial will cover the basics of how to use  SQLite  database in android.  Android uses SQLite database as one of the data storage options.  Lets have a look how we can use SQLite to perform the CRUD (create, retrieve, update, delete) operations. Before going directly into the CRUD operations we will have a look on how we are creating a database , a table in the database etc. For this we will be using a class that extends  SQLiteOpenHelper class.  In this class I am going to create a database and also a table in it and at the same time write logic for the CRUD operations. Lets have a look at the code for the creation of database and table.      public class DatabaseHelper extends SQLiteOpenHelper { private static String DATA_BASE = "employee_database"; private static String TABLE_NAME = "employee"; private static int DATABASE_VERSION = 3; String create_table = "CREATE TABLE  "+TABLE_NAME+" (id INTEGER PRIMARY               

Splash Screen

Splash Screen :              We can observe sometimes when we start any application we find an image which will be shown for few seconds before the actual content of the application is shown. This is a splash screen. Lets start a sample code where we discuss showing a splash screen. Design an xml file named splash.xml as below. <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:background="@drawable/splash_screen" > </RelativeLayout> Here splash_screen is an image that i want to set as a splash. Now let us code the activity file where the splash stays for 5 sec and is redirected to the main actual content of the app.               Write the following code in the onCreate() of the activity. public void onCreate(Bundle savedInstan

Localization using .ttf files

In my previous post  here  i gave some information on how to use the concept of localization for the languages that are supported by Android. Now suppose if u want to display a language that is not supported by android.......? Then what might be solution? I will be discussing a small example for doing this now. Suppose if you want to display some text like this " हिंदी " or  " தமிழ் " or  some thing like the text   here  any other language that is  not supported by android we can use .ttf files so that we can print the font we are interested. To achieve this first we need to download few .ttf files. You can google for a file you need, download it and place this into the assets folder. In the picture i am having few other ttf files which i included, But for the time being only the DroidSansRegionalAAd.ttf is discussed by me which i used to display the words of few languages of India as in the following picture. Now we need to refer to the ttf file i