Monday, 31 March 2014

ImageSwitter Functionality Creation in Android Apps


This blog describe about ImageSwitcher view of image gallery.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Simple Image Switcher"
        android:layout_gravity="center"
        android:textSize="20sp"
        android:layout_marginTop="10dp"
        android:textColor="#336633"
        android:textStyle="bold"/>

Saturday, 29 March 2014

WebView Functionality in Android Application Development


This blog about WebView creation in android apps development.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Web View"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

TabWidget HorizontalScrollView Functionality Using TabHost in Android Applications


In android applications TabWidget functionality is very useful feature. It help to quick tab navigation using HorizontalScrollView and display tab relevant screen.


main.xml


<LinearLayout 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:orientation="vertical" >

Thursday, 27 March 2014

Simple SlidingDrawer Functionality in Android Application Development

This blog described about most popular android feature sliding between two screen using tab or menu list icon. This feature can performed by using SlidingDrawer widget in android app it can be slide manually also.
Below is the simple code of SlidingDrawer functionality.

main.xml

<LinearLayout 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:orientation="vertical"   
     >

Wednesday, 26 March 2014

SearchView Functionality in Android Apps

When user want to get data from a list data quickly SearchView widget in android assist the user by filtering according to alphabet character or position of data. This blog describe about simple static search view functionality.



main.xml

<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search View"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold"
        android:layout_marginTop="20dp"
        android:layout_gravity="center"/>

Tuesday, 25 March 2014

HorizontalScrollView Creation in Android Apps

Some time android app need horizontal scroll view to complete this requirement can use HorizontalScrollView widget and implement in app.

main.xml

<LinearLayout 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:orientation="vertical" >

Monday, 24 March 2014

Simple ScrollView Creation in Android Apps Development

This blog is relevant to ScrollView creation in android application when size of data is more than screen's height of device. To populate large data in small screen device need scroll view. To create scroll view need ScrollView layout with single parent linearLayou or RelativeLayout. Can't include more than one linear or relative layout within scrollView layout. Can include more than one child linear or  relative layout within direct linear or relative layout of scrollView layout.

main.xml

<LinearLayout 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:orientation="vertical" >

Sunday, 23 March 2014

GridView Creation in Android Application

Simple GridView

This blog describe about display data in simple gridView.

main.xml

<LinearLayout 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="#7CFCff"
    android:orientation="vertical" >

Saturday, 22 March 2014

Static ExpandableListView Creation in Android App and Implementation

This blog describe about ExpandableListView creation in android apps. Through this can create more than one group including with multiple child data with each group with expand and hide list data feature.

main.xml

<LinearLayout 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:orientation="vertical" >

Saturday, 15 March 2014

Dynamic ListView Creation and Implementation Programatically in Android Application

Dynamic ListView

This blog describe about dynamic list view creation and implementation programatically in android apps. For this need to take array list and array adapter add item data list programatically . 

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/linearlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_dark"
    android:orientation="vertical" >

Friday, 14 March 2014

ListView Functionality Creation and Implementation in Android Applications

Static ListView

This post describe about static ListView functionality in android applications. For list view take string array list with list items in res->values->strings.xml editor and add this list item reference with list view entries in main.xml editor.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="List View"
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

Thursday, 13 March 2014

Different Types of Layout Creation in Android Application

Linear Layout

This blog describe about different types of layout which are used in android application's user interface development. Firstly described about LinearLayout. In this blog layout orientation is "vertical" and taken TextView, EditText, Button, CheckBox and RadioButton with LayouGravity Center.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Linear Layout"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:textColor="#336633"
        android:textSize="20dp"
        android:textStyle="bold"/>

Wednesday, 12 March 2014

How to Create VideoView Functionality and Implement in Android Apps


This blog describe how to create VideoView or video playing functionality in android applications with control functionality.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Static Video View"
        android:textColor="#336633"
        android:textSize="20dp"
        android:textStyle="bold"
        android:layout_marginTop="20dp"
        android:layout_gravity="center" />

// No need to write manually VideoView code in xml editor drag VideiView widget from left side Palette in // graphical view of xml editor

Tuesday, 11 March 2014

Implementation of AudioMediaPlayer Functionality in Android Applications

This blog is relevant to implementation of AudioMediaPlayer functionality in android applications. To get this functionality need raw folder in Resource (res) pan pest audio file in this folder.


main.xml


<LinearLayout 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:orientation="vertical">

    <Button
        android:id="@+id/btnStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Start"
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:textStyle="bold"/>
  
    <Button
        android:id="@+id/btnStop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Stop"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:textStyle="bold"/>
</LinearLayout>

Monday, 10 March 2014

How to Create ImageGallery and Implement in Android Apps

In this blog explain that how to create imageGallery and view gallery image individually in separate frame.


main.xml


<LinearLayout 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:orientation="vertical"
     >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Gallery View"
        android:layout_marginTop="10dp"
        android:layout_gravity="center"
        android:textColor="#339966"
        android:textSize="20sp"
        android:textStyle="bold"/>

Sunday, 9 March 2014

How to Implement DigitalClock in Android Apps

This blog explain that how to create and implement DigitalClock in android applications.


main.xml

<LinearLayout 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:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="Digital Clock"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

    <DigitalClock
        android:id="@+id/digitalClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:textSize="20dp" />

</LinearLayout>

DigitalClockActivity.java

Saturday, 8 March 2014

How to Implement AnalogClock Functionality in Android Application

This blog explain that how to create and implement AnalogClock functionality in android application.
In xml editor no need to write code manually you have to drag from palette Date & Time column of graphical view of xml editor.


main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="Analog Clock"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

<!--In xml editor no need to write code manually you have to drag from palette Date & Time column of graphical view of xml editor-->

    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
       android:background="#339966"
        android:layout_marginTop="80dp" />

</LinearLayout>

AnalogClockActivity.java

Friday, 7 March 2014

How to Create and Implement Chronometer in Android Application

In this blog you can learn how to create and implement chronometer in any android apps.To create it you have to drag Chronometer in main.xml graphical editor from palette-->Time & Date folder.
 Only there is click on start button to start chronometer functionality also can include functionality stop, restart, set format and clear format .


main.xml

<LinearLayout 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:orientation="vertical" >

  

Thursday, 6 March 2014

How to Create CalendarView Functionality in Android

In this blog you will learn how to implement CalendarView functionality in your android app.

main.xml

<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="Calendar View"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />





<--- Drag CalendarView from Paletee in xml editor from Time & Date -->
  
<CalendarView
        android:id="@+id/calendarView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp" />

</LinearLayout>

CalendarViewActivity.java

package com.rakesh.tiwari.calendarview;

import java.sql.Date;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CalendarView;
import android.widget.CalendarView.OnDateChangeListener;
import android.widget.Toast;

public class CalendarViewActivity extends Activity {
    CalendarView calendar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        calendar = (CalendarView) findViewById(R.id.calendarView1);
        calendar.setOnDateChangeListener(new OnDateChangeListener() {

            @Override
            public void onSelectedDayChange(CalendarView view, int year,
                    int month, int dayOfMonth) {
                // TODO Auto-generated method stub
                Toast.makeText(
                        getApplicationContext(),
                        "Selected date is :\n\n" + dayOfMonth + "-" + month
                                + "-" + year, Toast.LENGTH_LONG).show();
            }
        });
    }

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rakesh.tiwari.calendarview"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.rakesh.tiwari.calendarview.CalendarViewActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


CalendarView Functionality

CalendarView Functionality

CalendarView 

CalendarView Implementation

CalendarView Functionality

Wednesday, 5 March 2014

Android - How to Create DatePicker Functionality in Your Android App

This blog teach you how to perform DatePicker functionality and set day, month, and year.

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="Date Picker"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

<--- Drag DatePicker from Paletee in xml editor from Time & Date -->

    <DatePicker
        android:id="@+id/datePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="50dp" />

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="80dp"
        android:text="Set Date"
        android:textStyle="bold" />

</LinearLayout>

DatePickerActivity.java


package com.rakesh.tiwari.datepicker;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Toast;

public class DatePickerActivity extends Activity {
DatePicker date;
Button setdate;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
date = (DatePicker) findViewById(R.id.datePicker1);
setdate = (Button) findViewById(R.id.button1);

setdate.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(
getApplicationContext(),
"Date is :" + date.getDayOfMonth() + "-"
+ (date.getMonth() + 1) + "-" + date.getYear(),
Toast.LENGTH_LONG).show();
}
});

}

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rakesh.tiwari.datepicker"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.rakesh.tiwari.datepicker.DatePickerActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>






Tuesday, 4 March 2014

Android - How to Create TimePicker Android App

This blog will teach you how to create timePicker and set time.

main.xml

<LinearLayout 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:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:text="Time Picker"
        android:textColor="#336633"
        android:textSize="20sp"
        android:textStyle="bold" />

    <TimePicker
        android:id="@+id/timePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_gravity="center"
        android:layout_marginTop="50dp" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="80dp"
        android:text="Set Time"
        android:textSize="20sp"
        android:textStyle="bold" />

</LinearLayout>

TimePickerActivity.java

package com.rakesh.tiwari.timepicker;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TimePicker;
import android.widget.TimePicker.OnTimeChangedListener;
import android.widget.Toast;

public class TimePickerActivity extends Activity {
    TimePicker tmpkr;
    Button settime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tmpkr = (TimePicker) findViewById(R.id.timePicker1);
        settime = (Button) findViewById(R.id.button1);
        tmpkr.setOnTimeChangedListener(new OnTimeChangedListener() {

            @Override
            public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(),
                        "Time is:" + hourOfDay + minute, Toast.LENGTH_LONG)
                        .show();
            }
        });

        settime.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Toast.makeText(
                        getApplicationContext(),
                        "Time is :" + tmpkr.getCurrentHour()
                                + tmpkr.getCurrentMinute(), Toast.LENGTH_LONG)
                        .show();
            }
        });
    }

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rakesh.tiwari.timepicker"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name="com.rakesh.tiwari.timepicker.TimePickerActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


TimePicker

TimePicker Functionality

TimePicker Implementation

Monday, 3 March 2014

How to Create ImageButton Click Function in Android


In this blog you will learn how to create ImageButton and perform click and onLongClick event on imageButton through click event.

main.xml

<LinearLayout 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:orientation="vertical"
     >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Image Button"
        android:textColor="#336633"
        android:textStyle="bold"
        android:layout_marginTop="40dp"
        android:textSize="20sp" />


<--- Drag ImageButton from Paletee in xml editor from Images & Media -->

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

ImageButtonActivity.java


package com.rakesh.tiwari.imagebutton;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class ImageButtonActivity extends Activity {

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

final ImageButton imgbtn=(ImageButton)findViewById(R.id.imageButton1);

// Perform onclick event

imgbtn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

// Set different imageResource with ImageButton

imgbtn.setImageResource(R.drawable.yellowstar);

Toast.makeText(getApplicationContext(), "Image Button Clicked", Toast.LENGTH_LONG).show();
}
});

// Perform LongPress click event

imgbtn.setOnLongClickListener(new View.OnLongClickListener() {

@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
imgbtn.setImageResource(R.drawable.greenstar);
Toast.makeText(getApplicationContext(), "Image Button Long Pressed", Toast.LENGTH_LONG).show();
return false;
}
});
}


}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rakesh.tiwari.imagebutton"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name="com.rakesh.tiwari.imagebutton.ImageButtonActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>







Sunday, 2 March 2014

How to Create ImageView and Image Change View in Android

main.xml


<LinearLayout 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:orientation="vertical" >

    <TextView
      
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Image View"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:textColor="#336633"
        android:textStyle="bold"
        android:textSize="20sp"/>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:src="@drawable/ic_launcher" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:text="Button" />

</LinearLayout>

ImageViewActivity.java

package com.rakesh.tiwari.imageview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class ImageViewActivity extends Activity {
ImageView img;
Button btn;
int value = 0;

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

img = (ImageView) findViewById(R.id.imageView1);
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

if (value == 0) {

img.setImageResource(R.drawable.yellowstar);
value = 1;
} else if (value == 1) {

img.setImageResource(R.drawable.greenstar);
value = 2;
} else if (value == 2) {

img.setImageResource(R.drawable.redstar);

value = 0;
}
}
});

}

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rakesh.tiwari.imageview"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name="com.rakesh.tiwari.imageview.ImageViewActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>









Saturday, 1 March 2014

How to Create MultiAutoComplete TextView Creation

main.xml

<LinearLayout 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:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Multi Auto Complete TextView"
        android:layout_marginTop="20dp"
        android:layout_gravity="center"
        android:textColor="#336633"
        android:textStyle="bold"
        android:textSize="20sp"/>

    <MultiAutoCompleteTextView
        android:id="@+id/multiAutoCompleteTextView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="MultiAutoCompleteTextView"
        android:layout_gravity="center"
        android:layout_marginTop="40dp" >

        <requestFocus />
    </MultiAutoCompleteTextView>

</LinearLayout>

MultiAutoCompleteTextViewActivity.java

package com.anju.tiwari.multiautocompletetextview;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.MultiAutoCompleteTextView;

public class MultiAutoCompleteTextViewActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String[] str = { "Andoid", "Jelly Bean", "Froyo", "Ginger Bread",
                "Eclipse Indigo", "Eclipse Juno", "About Eclipse",
                "Mobile Android", "Mobile Window", "Smart Phone" };

        MultiAutoCompleteTextView mltatotv = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);

        mltatotv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

        ArrayAdapter<String> adptr = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, str);

        mltatotv.setThreshold(1);

        mltatotv.setAdapter(adptr);
    }

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.anju.tiwari.multiautocompletetextview"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name="com.anju.tiwari.multiautocompletetextview.MultiAutoCompleteTextViewActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>