Search Wikipedia

Search results

Mar 27, 2014

Using Google Maps V2 in Android

1. Downloading Google Play Services

Google made new Maps V2 API as a part of Google Play Services SDK. So before we start developing maps we need to download google play services from SDK manger. You can open SDK manager either from Eclipse or from android sdk folder.
Open Eclipse ⇒ Windows ⇒ Android SDK Manager and check whether you have already downloaded Google Play Services or not under Extras section. If not select play services and install the package.

Downloading Google Play Services

2.Importing Google Play Services in Eclipse

After downloading play services we need to import it to Eclipse which will be used as a library for our maps project.
1. In Eclipse goto File ⇒ Import ⇒ Android ⇒ Existing Android Code Into Workspace
2. Click on Browse and select Google Play Services project from your android sdk folder. You can locate play services library project from
android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib
3. Importantly while importing check Copy projects into workspace option as shown in the below image.

Importing Google Play Services

Dec 17, 2013

Working with Camera in Android

Taking a Picture in Android


Create a new project in Eclipse from File ⇒ New ⇒ Android ⇒ Application Project and fill all the required information. I left my main activity as MainActivity.java

Working with camera needs set of permissions and features in the AndroidManifest.xml file. Add following in your AndroidManifest.xml

android.hardware.camera – Required to use camera hardware
Adding required permissions in manifest file

Dec 10, 2013

Custom Dialog in Android

Creating a Custom Dialog in Android

I create a new android application project called "Custon_dialog"
Then I need to create a custom layout for my custom dialog and for this I create a new xml file called "dialog.xml"
In my custom dialog i want to show a picture and  some texts.
So, i drag a picture in my drawable folder.

dialog.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="110dp"
        android:layout_height="160dp"
        android:contentDescription="@string/todo"
        android:padding="20dp"
        android:src="@drawable/android" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="170dp"
        android:layout_height="211dp"
        android:text="@string/i_love_android" 
        android:textSize="25sp"/>

</LinearLayout>

Android Custom ListView With Images And Text

Customizing of ListView 

Today I am gonna customize the listview with images and text.
For this I create a new project called "Listv"
Then I drag a listview in "activity_main" xml file.


This xml file code looks like this:

<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"
    tools:context=".MainActivity" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </ListView>
</RelativeLayout>

Dec 5, 2013

Customization of Gridview

Customizing the Gridview 


After completion of simple gridview, now I am going to customize that gridview like opening the full-sized images from gridview and naming the images of the gridview.

For this, i create a new android project called "Grid_cus"
As we have done before, drag the gridview layout in graphical layout as shown below:

Draging Gridview in the layout


As like before tutorial, place the pictures in res->drawable-hdpi folder.
Then  i create a new class called "ImageControl.java" and write these codes :

public class ImageControl extends BaseAdapter{
Context mcontext;

public  static int[] ImageIds= { R.drawable.a, R.drawable.a1,R.drawable.a2, R.drawable.a3,
R.drawable.f, R.drawable.e,R.drawable.a7, R.drawable.a6,R.drawable.a5, R.drawable.a4,R.drawable.r, R.drawable.a1,R.drawable.v};

String texts[] = new String[]{"good","best","bad","damn","lool","joker","hard",
"kool","magic","aaare","pop","rock"};

public ImageControl(Context context){
mcontext = context;
}

Dec 3, 2013

Basic GridView Layout in Android

Creating a Basic GridView Layout in android

 GridView is a viewGroup that displays items in a two-dimensional,scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.

Today i am gonna create a simple Gridview layout.Now  I prepare images which i want to show in grid layout and place them in res->drawable-hdpi folder.

Images in Drawable-hdpi which will be shown in Gridview

I go to activity_main.xml and drag gridview layout from Palette or I can also write code directly for gridview which will be like this:

activity_main.xml

Oct 18, 2013

Content menu in Android

  Creating a Content Menu


Android has a unique mechanism called long press.
 When we click any button or image for long time a kind of menu appears that is called content menu.

Today i am doing a project related to this.
First of all i create a project called "Content_menu".
Then go to XML file.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

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"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="106dp"
        android:layout_marginTop="159dp"
        android:text="@string/button" />
</RelativeLayout>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Adding a button in xml

Then i create a new xml file called contentmenu.xml
Note: Choose menu in Resource Type

Creating a new XML file

}