Wednesday 1 October 2014

Registration Login and Forgot password UI ANDROID

REGISTRATION SCREEN XML Layout Android:-





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/register_main"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true" >

    <View
        android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true" />

    <ScrollView
        android:id="@+id/ScrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/view"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/registration_background"
        android:padding="25dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/Register_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Register"
                android:textSize="30dp"
                android:textStyle="bold"
                android:typeface="monospace" />

            <EditText
                android:id="@+id/username_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/Register_tv"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_uname"
                android:gravity="center"
                android:hint="Username"
                android:inputType="text"
                android:textColor="#000000"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/passwd_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/username_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_password"
                android:gravity="center"
                android:hint="Password"
                android:inputType="textPassword"
                android:textColor="#000000"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/cnfpasswd_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/passwd_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_cnfpassword"
                android:gravity="center"
                android:hint="Confirm Password"
                android:inputType="textPassword"
                android:textColor="#000000"
                android:textStyle="bold" />

            <Button
                android:id="@+id/register_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/cnfpasswd_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_button"
                android:text="REGISTER"
                android:textColor="#ffffff"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/member_login_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/register_button"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Memeber Login?"
                android:textSize="15dp"
                android:textStyle="bold"
                android:typeface="monospace" />
        </RelativeLayout>
    </ScrollView>

    <ImageView
        android:id="@+id/view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:background="@drawable/register_imview" />

</RelativeLayout>

LOGIN SCREEN XML layout Android Code:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/register_main"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true" >

    <View
        android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true" />

    <ScrollView
        android:id="@+id/ScrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/view"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/registration_background"
        android:padding="25dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/member_login_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Member Login"
                android:textSize="25dp"
                android:textStyle="bold"
                android:typeface="monospace" />

            <EditText
                android:id="@+id/username_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/member_login_tv"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_uname"
                android:gravity="center"
                android:hint="Username"
                android:inputType="text"
                android:textColor="#000000"
                android:textStyle="bold" />

            <EditText
                android:id="@+id/passwd_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/username_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_password"
                android:gravity="center"
                android:hint="**************"
                android:inputType="textPassword"
                android:textColor="#000000"
                android:textStyle="bold" />

            <Button
                android:id="@+id/login_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/passwd_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_button"
                android:text="LOGIN"
                android:textColor="#ffffff"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/forgot_passwd_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/login_button"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Forgot Password?"
                android:textSize="15dp"
                android:textStyle="bold"
                android:typeface="monospace" />
        </RelativeLayout>
    </ScrollView>

    <ImageView
        android:id="@+id/view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:background="@drawable/member_imview" />

</RelativeLayout>


FORGOT PASSWORD XML Layout in Android:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/register_main"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true" >

    <View
        android:id="@+id/view"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true" />

    <ScrollView
        android:id="@+id/ScrollView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/view"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:background="@drawable/registration_background"
        android:padding="25dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/member_login_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Forgot Password"
                android:textSize="20dp"
                android:textStyle="bold"
                android:typeface="monospace" />

            <EditText
                android:id="@+id/email_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/member_login_tv"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_uname"
                android:gravity="center"
                android:hint="Email Id"
                android:inputType="textEmailAddress"
                android:textColor="#000000"
                android:textStyle="bold" />

           <!--  <EditText
                android:id="@+id/passwd_edtext"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/username_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_password"
                android:gravity="center"
                android:hint="**************"
                android:inputType="textPassword"
                android:textColor="#000000"
                android:textStyle="bold" /> -->

            <Button
                android:id="@+id/login_button"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/email_edtext"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="25dp"
                android:background="@drawable/register_button"
                android:text="SEND"
                android:textColor="#ffffff"
                android:textSize="20dp" />

          <!--   <TextView
                android:id="@+id/tv_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/login_button"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="30dp"
                android:text="Forgot Password?"
                android:textSize="15dp"
                android:textStyle="bold"
                android:typeface="monospace" /> -->
        </RelativeLayout>
    </ScrollView>

    <ImageView
        android:id="@+id/view_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:background="@drawable/member_imview" />

</RelativeLayout>


Please download all the images for Ui for Screens:








Thursday 19 June 2014

Android Bus Ticket App Source code

Screen Layout for Android XML


activity_seat_selection_screen.xml


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

    <include
        android:id="@+id/header"
        layout="@layout/common_header_with_sub_title" />

    <RelativeLayout
        android:id="@+id/busDeckSelectionLayout"
        android:layout_width="fill_parent"
        android:layout_height="45.0dip"
        android:layout_below="@+id/header" >

        <RelativeLayout
            android:id="@+id/busDeckSelectionButtons"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="#ffeeeeee" >

            <Button
                android:id="@+id/lowerDeck"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:background="@drawable/left_button"
                android:text="@string/lower"
                android:textColor="@color/black"
                android:textSize="12.0sp" />

            <Button
                android:id="@+id/upperDeck"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/lowerDeck"
                android:background="@drawable/right_button"
                android:text="@string/upper"
                android:textColor="@color/black"
                android:textSize="12.0sp" />
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:id="@+id/busDeckSelectionMargin"
        android:layout_width="fill_parent"
        android:layout_height="1.0dip"
        android:layout_below="@+id/busDeckSelectionLayout"
        android:background="#ffdddddd" />

    <RelativeLayout
        android:id="@+id/seatSelectionHeader"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/busDeckSelectionMargin" >

        <RelativeLayout
            android:id="@+id/seatsLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="5.0dip"
            android:layout_marginTop="5.0dip" >

            <TextView
                android:id="@+id/seatsSelectedText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:text="@string/seats_selected"
                android:textColor="@color/black"
                android:textSize="12.0sp" />

            <TextView
                android:id="@+id/seatsSelected"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/seatsSelectedText"
                android:layout_marginTop="10.0dip"
                android:textColor="@color/black"
                android:textSize="14.0sp" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/fareLayout"
            android:layout_width="wrap_content"
            android:layout_height="40.0dip"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@+id/seatsLayout"
            android:background="@layout/fare_seat_selection_background" >

            <TextView
                android:id="@+id/rsText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginBottom="10.0dip"
                android:layout_marginLeft="5.0dip"
                android:layout_marginTop="10.0dip"
                android:text="@string/rupees"
                android:textColor="@color/black"
                android:textSize="18.0sp" />

            <TextView
                android:id="@+id/fare"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginBottom="10.0dip"
                android:layout_marginRight="5.0dip"
                android:layout_marginTop="10.0dip"
                android:textColor="@color/black"
                android:textSize="18.0sp" />
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:id="@+id/seatSelectionHeaderMargin"
        android:layout_width="fill_parent"
        android:layout_height="1.0dip"
        android:layout_below="@+id/seatSelectionHeader"
        android:background="#ffdddddd" />

    <RelativeLayout
        android:id="@+id/seatLayoutScroll"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bottomBarSeatSelection"
        android:layout_below="@+id/seatSelectionHeaderMargin"
        android:background="@color/white" >

        <RelativeLayout
            android:id="@+id/scrollableLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <RelativeLayout
                android:id="@+id/seatLegendLayout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5.0dip"
                android:layout_marginTop="5.0dip" >

                <RelativeLayout
                    android:id="@+id/availableImageLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true" >

                    <ImageView
                        android:id="@+id/availableImage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_marginLeft="10.0dip"
                        android:rotation="90.0"
                        android:src="@drawable/seat_layout_tab_nor_avl" />

                    <TextView
                        android:id="@+id/availableText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5.0dip"
                        android:layout_toRightOf="@+id/availableImage"
                        android:text="@string/available"
                        android:textSize="12.0sp" />
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/bookedImageLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_toRightOf="@+id/availableImageLayout" >

                    <ImageView
                        android:id="@+id/bookedImage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="10.0dip"
                        android:rotation="90.0"
                        android:src="@drawable/seat_layout_tab_nor_bkd" />

                    <TextView
                        android:id="@+id/bookedText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5.0dip"
                        android:layout_toRightOf="@+id/bookedImage"
                        android:text="@string/booked"
                        android:textSize="12.0sp" />
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/selectedImageLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_toRightOf="@+id/bookedImageLayout" >

                    <ImageView
                        android:id="@+id/selectedImage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10.0dip"
                        android:rotation="90.0"
                        android:src="@drawable/seat_layout_tab_nor_std" />

                    <TextView
                        android:id="@+id/selectedText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5.0dip"
                        android:layout_toRightOf="@+id/selectedImage"
                        android:text="@string/selected"
                        android:textSize="12.0sp" />
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/ladiesImageLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/availableImageLayout"
                    android:layout_marginTop="5.0dip" >

                    <ImageView
                        android:id="@+id/ladiesImage"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="10.0dip"
                        android:rotation="90.0"
                        android:src="@drawable/seat_layout_tab_nor_lad_avl" />

                    <TextView
                        android:id="@+id/ladiesText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5.0dip"
                        android:layout_toRightOf="@+id/ladiesImage"
                        android:text="@string/ladies"
                        android:textSize="12.0sp" />
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/seatLayoutLowerMain"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:layout_below="@+id/seatLegendLayout"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10.0dip"
                android:background="@layout/seat_layout_border"
                android:paddingBottom="5.0dp"
                android:paddingRight="5.0dp" >

                <GridView
                    android:id="@+id/gridView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_margin="4dp"
                    android:columnWidth="100dp"
                    android:gravity="center"
                    android:numColumns="4"
                    android:stretchMode="columnWidth"
                    android:layout_below="@+id/driver" >
                </GridView>
               
                <RelativeLayout
                    android:id="@+id/driver"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_alignRight="@+id/gridView1"
                    android:layout_marginRight="20.0dp"
                    android:layout_marginTop="5.0dp"
                    android:background="@drawable/steering_icon"
                    android:orientation="horizontal" >
                </RelativeLayout>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/seatLayoutUpper"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/seatLegendLayout"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10.0dip"
                android:background="@layout/seat_layout_border"
                android:visibility="invisible" />
        </RelativeLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/bottomBarSeatSelection"
        android:layout_width="fill_parent"
        android:layout_height="49.0dip"
        android:layout_alignParentBottom="true"
        android:background="@color/white" >

        <Button
            android:id="@+id/doneButton"
            android:layout_width="160.0dip"
            android:layout_height="48.0dip"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="1.0dip"
            android:background="@drawable/selector_red_btn"
            android:text="@string/done"
            android:textColor="@color/white"
            android:textSize="18.0sp" />

        <Button
            android:id="@+id/cancelButton"
            android:layout_width="160.0dip"
            android:layout_height="48.0dip"
            android:layout_alignParentRight="true"
            android:layout_marginTop="1.0dip"
            android:background="@drawable/selector_black_btn"
            android:text="@string/goBack"
            android:textColor="@color/white"
            android:textSize="18.0sp" />
    </RelativeLayout>

</RelativeLayout>

Android Java Code For Seat Selection


SeatSelectionActivity.java

package com.ipay.mobilemoney;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;

import com.ipay.arrayadapter.CustomGridViewAdapter;
import com.ipay.arrayadapter.CustomGridViewAdapter.RecordHolder;
import com.ipay.arrayadapter.Item;

/**
 *
 * @author Saurabh tomar
 *
 */

public class SeatSelectionActivityNew extends Activity implements OnItemClickListener
{
    GridView gridView;
    ArrayList<Item> gridArray = new ArrayList<Item>();
    CustomGridViewAdapter customGridAdapter;
    public Bitmap seatIcon;
    public Bitmap seatSelect;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seat_selection_screen);

        // set grid view item
        seatIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.seat_layout_screen_nor_avl);
        seatSelect = BitmapFactory.decodeResource(this.getResources(), R.drawable.seat_layout_screen_nor_std);
        totalSeat(50);

        gridView = (GridView) findViewById(R.id.gridView1);
        customGridAdapter = new CustomGridViewAdapter(this, R.layout.seatrow_grid, gridArray);
        gridView.setAdapter(customGridAdapter);
        gridView.setOnItemClickListener(this);
    }

    public void totalSeat(int n)
    {
        for (int i = 1; i <= n; ++i)
        {
            gridArray.add(new Item(seatIcon, "seat " + i));

        }
    }

    public void seatSelected(int pos)
    {
        gridArray.remove(pos);
        gridArray.add(pos, new Item(seatSelect, "select"));
        customGridAdapter.notifyDataSetChanged();
    }

    public void seatDeselcted(int pos)
    {

        gridArray.remove(pos);
        int i = pos + 1;
        gridArray.add(pos, new Item(seatIcon, "seat" + i));
        customGridAdapter.notifyDataSetChanged();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    {

        Item item = gridArray.get(position);
        Bitmap seatcompare = item.getImage();
        if (seatcompare == seatIcon)
        {
            seatSelected(position);
        }
        else
        {
            seatDeselcted(position);

        }

    }

}

Custom Array Adapter For GridView

package com.ipay.arrayadapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.ipay.mobilemoney.R;

/**
 *
 * @author Saurabh Tomar
 *
 */
public class CustomGridViewAdapter extends ArrayAdapter<Item>
{

    Context context;
    int layoutResourceId;
    ArrayList<Item> data = new ArrayList<Item>();

    public CustomGridViewAdapter(Context context, int layoutResourceId, ArrayList<Item> data)
    {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        View row = convertView;
        RecordHolder holder = null;

        if (row == null)
        {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);

            holder = new RecordHolder();
            holder.txtTitle = (TextView) row.findViewById(R.id.item_text);
            holder.imageItem = (ImageView) row.findViewById(R.id.item_image);
            row.setTag(holder);
        }
        else
        {
            holder = (RecordHolder) row.getTag();
        }

        Item item = data.get(position);
        holder.txtTitle.setText(item.getTitle());
        holder.imageItem.setImageBitmap(item.getImage());

        return row;
    }

    public static class RecordHolder
    {
        public TextView txtTitle;
        public ImageView imageItem;

    }
}

OUTPUT FROM THE CODE: