Open top menu

Make Square GridView Cells Height and Width in android?






In this blog we will explain how to implement square gridview cells in GridView Layout. The GridView Cells measuring height and width automatically.

Step:1 create imageview class inside src folder .
...................................................................................................................................................................

public class SquareImageView extends ImageView {
public SquareImageView(Context context)
   {
       super(context);
   }

   public SquareImageView(Context context, AttributeSet attrs)
   {
       super(context, attrs);
   }

   public SquareImageView(Context context, AttributeSet attrs, int defStyle)
   {
       super(context, attrs, defStyle);
   }

   @Override
   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
   {
       super.onMeasure(widthMeasureSpec, heightMeasureSpec);
       
       setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());  
   }

}

Step:2 create griview cell view class inside res/layout folder.
gridview_item,xml
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff">
    
    <com.example.androidtestcode.SquareImageView
        android:id="@+id/picture"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:scaleType="fitXY"
        android:padding="10dp"
        android:background="@drawable/border" />       
</FrameLayout>


Step:3 create expandable gridview class inside src folder..

ExpandableHeightGridView .java
...................................................................................................................................................................



public class ExpandableHeightGridView extends GridView {

boolean expanded = false;

public ExpandableHeightGridView(Context context)
{
    super(context);
}

public ExpandableHeightGridView(Context context, AttributeSet attrs)
{
    super(context, attrs);
}

public ExpandableHeightGridView(Context context, AttributeSet attrs,
        int defStyle)
{
    super(context, attrs, defStyle);
}

public boolean isExpanded()
{
    return expanded;
}

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
    // HACK! TAKE THAT ANDROID!
    if (isExpanded())
    {
        // Calculate entire height by providing a very large height hint.
        // View.MEASURED_SIZE_MASK represents the largest height possible.
        int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);

        ViewGroup.LayoutParams params = getLayoutParams();
        params.height = getMeasuredHeight();
    }
    else
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}

public void setExpanded(boolean expanded)
{
    this.expanded = expanded;
} }


Step:3create main xml class inside res/layout folder.
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:background="#000000"
    android:gravity="center"
     >

    <com.example.androidtestcode.ExpandableHeightGridView
        android:id="@+id/gridview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:verticalSpacing="4dp"
        android:horizontalSpacing="4dp"   
        android:stretchMode="columnWidth"               
        android:numColumns="3"
        android:layout_margin="3dp"
        android:direction="top_to_bottom|left_to_right"
       />
</RelativeLayout>




Step:4 create gridview adatpter class inside src folder.
Adapter.java.
...................................................................................................................................................................


public class Adapter  extends BaseAdapter{
private List<Item> items = new ArrayList<Item>();
     private LayoutInflater inflater;

     public Adapter(Context context)
     {
         inflater = LayoutInflater.from(context);
         items.add(new Item("Image 1", R.drawable.logo));
         items.add(new Item("Image 2", R.drawable.logo));
         items.add(new Item("Image 3", R.drawable.logo));
         items.add(new Item("Image 4", R.drawable.logo));
         items.add(new Item("Image 5", R.drawable.logo));
         items.add(new Item("Image 6", R.drawable.logo));
         items.add(new Item("Image 7", R.drawable.logo));
         items.add(new Item("Image 8", R.drawable.logo));
         items.add(new Item("Image 9", R.drawable.logo));
     }

     @Override
     public int getCount() {
         return items.size();
     }

     @Override
     public Object getItem(int i)
     {
         return items.get(i);
     }

     @Override
     public long getItemId(int i)
     {
         return items.get(i).drawableId;
     }

     @SuppressLint("NewApi")
@Override
     public View getView(int i, View view, ViewGroup viewGroup)
     {
         View v = view;
         SquareImageView picture;
         

         if(v == null)
         {
            v = inflater.inflate(R.layout.gridview_item, viewGroup, false);
            v.setTag(R.id.picture, v.findViewById(R.id.picture));
            v.setBottom(23);
         }

         picture = (SquareImageView)v.getTag(R.id.picture);
         

         Item item = (Item)getItem(i);

         picture.setImageResource(item.drawableId);
        
         

         return v;
     }

     private class Item
     {
          
         final int drawableId;

         Item(String name, int drawableId)
         {
             
             this.drawableId = drawableId;
         }
     }
 }


Step:5 create main java class inside src folder.
MainActivity.java.
...................................................................................................................................................................

public class MainActivity extends  Activity {
ExpandableHeightGridView gridView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
 
gridView = (ExpandableHeightGridView) findViewById(R.id.gridview);
 
gridView.setAdapter(new Adapter(this));
 }
}


Read more

 How to Add fragmnet In Activity programmatically in android?


In this blog we will explain Step by Step how to Add fragment in Activity . Show below

Step 1: create MainActivtiy  class in src folder...
MainActivity.java
...................................................................................................................................................................

package com.androidbeginner.testcode;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

@SuppressLint("ResourceAsColor")
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setTitle("Add Fragment");
setContentView(R.layout.activity_main);
final LinearLayout frgmentss=(LinearLayout)findViewById(R.id.fragment);
Button btnfragmnet=(Button)findViewById(R.id.button1);
btnfragmnet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// get an instance of FragmentTransaction from your Activity
      FragmentManager fragmentManager = getFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

      //add a fragment
      TestFragmnet myFragment = new TestFragmnet();
      fragmentTransaction.add(frgmentss.getId(), myFragment);
      fragmentTransaction.commit();
}
});
 
}

}
...................................................................................................................................................................


Step 2: create activity_main xml class inside res/layout folder
activity_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"
    android:gravity="center"
    android:id="@+id/fragment" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Add Fragment" />

</LinearLayout>
...................................................................................................................................................................

Step 3.create fragmnet view xml class inside res/layout folder.
fragmnet_layout.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:orientation="vertical"
    android:background="#ffffff">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/logoweb" />
        
</RelativeLayout>
...................................................................................................................................................................
Step 4: Create fragement java class inside src folder .
TestFragmnet .java
...................................................................................................................................................................

package com.androidbeginner.testcode;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class TestFragmnet extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.fragment_layout, container, false);
 
return myFragmentView;
}

}
.................................................................................................................................................................

try this code...




Read more

    

In this blog explain how to shared android app.

Step 1 first, add this code  in manifest file.



<activity android:name="com.oxample.tickmyad.ShareApp" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="text/plain" />
            </intent-filter>
        </activity>
   

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <activity android:name="com.example.tickmyad.ShareApp" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="text/plain" />
            </intent-filter>
        </activity>  
    </application>

</manifest>



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.androidtestcode.MainActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="150dp"
        android:text="share App" />

</RelativeLayout>



MainActivity.java.
................................................................................................................................................................
package com.example.androidtestcode;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends  Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent shareIntent = new Intent(Intent.ACTION_SEND);
// set  text type
shareIntent.setType("text/plain");
// set share url
shareIntent.putExtra(Intent.EXTRA_TEXT, "Click                                                                                                                                    On,http://androidbeginnerpoint.blogspot.in/");
startActivity(Intent.createChooser(shareIntent, "Share"));
}
});
}

}
...................................................................................................................................................................
try this code...











Read more

Water Ripple Animation in Android

In this blog implement water ripple animation .explain the code...

In this blog used some extra xml and java class.click here

Step 1. In this class you can set the RippleBackground class attrs accordingly.
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:id="@+id/ScrollView1"
            android:background="#4b70dd"
             >

            <com.webnetware.view.RippleBackground
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="-4dip"
                app:rb_color="#a9d3ec"
                app:rb_duration="3000"
                app:rb_radius="64dp"
                app:rb_rippleAmount="7"
                app:rb_scale="14" >

                 

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:contentDescription="@null"
                    android:src="@drawable/forword_arrow" />
            </com.webnetware.view.RippleBackground>
        </RelativeLayout>

...................................................................................................................................................................

MainActivity.java.
..................................................................................................................................................................

import java.util.ArrayList;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;

import com.webnetware.singingbowl.R;
import com.webnetware.view.RippleBackground;

public class Splash_ScreenActivity extends Activity{
 RippleBackground rippleBackground;
 ImageView image;
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
 
super.onCreate(savedInstanceState);
setContentView(R.layout.term_and_activity);
rippleBackground=(RippleBackground)findViewById(R.id.content);
image = (ImageView) findViewById(R.id.imageView);
rippleBackground.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

rippleBackground.startRippleAnimation();
foundDevice(image);
}
});
...................................................................................................................................................................

Open first Screen.


Start the animation ,when you click on layout.





Read more

Water Ripple effect onClick Layout in Android

In this blog explain how to show water effcte onclick layout in android. explain how

Step 1.Create attrs xml class in res/value/attrs.xml. In this class write a attr name as per rquire...
attrs.xml.
..................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="RippleBackground">
        
        <attr name="rb_color" format="color" />
        <attr name="rb_strokeWidth" format="dimension"/>
        <attr name="rb_radius" format="dimension"/>
        <attr name="rb_duration" format="integer"/>
        <attr name="rb_rippleAmount" format="integer"/>
        <attr name="rb_scale" format="float"/>
        
        <attr name="rb_type" format="enum">
            <enum name="fillRipple" value="0"/>
            <enum name="strokeRipple" value="0"/>
        </attr>
        
    </declare-styleable>

   
    
</resources>
..................................................................................................................................................................

Step 2 Create dimentions xml class inside res/value/dimentions.xml. In this class add dimen ripple width or ripple radius accordingly. 
dimentions.xml
..................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <dimen name="rippleStrokeWidth">2dp</dimen>
    <dimen name="rippleRadius">64dp</dimen>
</resources>
..................................................................................................................................................................

Step 3.Create RippleBackground  xml  layout via programmatically.

 RippleBackground .java
.................................................................................................................................................................

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.RelativeLayout;

import java.util.ArrayList;

import com.webnetware.singingbowl.R;



public class RippleBackground extends RelativeLayout{

    private static final int DEFAULT_RIPPLE_COUNT=12;
    private static final int DEFAULT_DURATION_TIME=3000;
    private static final float DEFAULT_SCALE=12.0f;
    private static final int DEFAULT_FILL_TYPE=0;

    private int rippleColor;
    private float rippleStrokeWidth;
    private float rippleRadius;
    private int rippleDurationTime;
    private int rippleAmount;
    private int rippleDelay;
    private float rippleScale;
    private int rippleType;
    private Paint paint;
    private boolean animationRunning=false;
    private AnimatorSet animatorSet;
    private ArrayList<Animator> animatorList;
    private LayoutParams rippleParams;
 
    private ArrayList<RippleView> rippleViewList=new ArrayList<RippleView>();

    public RippleBackground(Context context) {
        super(context);
    }

    public RippleBackground(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public RippleBackground(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    private void init(final Context context, final AttributeSet attrs) {
        if (isInEditMode())
            return;

        if (null == attrs) {
            throw new IllegalArgumentException("Attributes should be provided to this view,");
        }

        final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
        rippleColor=typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippelColor));
        rippleStrokeWidth=typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDimension(R.dimen.rippleStrokeWidth));
        rippleRadius=typedArray.getDimension(R.styleable.RippleBackground_rb_radius,getResources().getDimension(R.dimen.rippleRadius));
        rippleDurationTime=typedArray.getInt(R.styleable.RippleBackground_rb_duration,DEFAULT_DURATION_TIME);
        rippleAmount=typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount,DEFAULT_RIPPLE_COUNT);
        rippleScale=typedArray.getFloat(R.styleable.RippleBackground_rb_scale,DEFAULT_SCALE);
        rippleType=typedArray.getInt(R.styleable.RippleBackground_rb_type,DEFAULT_FILL_TYPE);
     
        typedArray.recycle();

        rippleDelay=rippleDurationTime/rippleAmount;

        paint = new Paint();
        paint.setAntiAlias(true);
        if(rippleType==DEFAULT_FILL_TYPE){
            rippleStrokeWidth=0;
            paint.setStyle(Paint.Style.FILL);
        }else
            paint.setStyle(Paint.Style.STROKE);
        paint.setColor(rippleColor);

        rippleParams=new LayoutParams((int)(2*(rippleRadius+rippleStrokeWidth)),(int)(2*(rippleRadius+rippleStrokeWidth)));
        rippleParams.addRule(CENTER_IN_PARENT, TRUE);

        animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorList=new ArrayList<Animator>();

            for(int i=0;i<rippleAmount;i++){
           
            RippleView rippleView=new RippleView(getContext());
            addView(rippleView,rippleParams);
            rippleViewList.add(rippleView);
         
            final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
            scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
            scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
            scaleXAnimator.setStartDelay(i * rippleDelay);
            scaleXAnimator.setDuration(rippleDurationTime);
            animatorList.add(scaleXAnimator);
         
            final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
            scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
            scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
            scaleYAnimator.setStartDelay(i * rippleDelay);
            scaleYAnimator.setDuration(rippleDurationTime);
            animatorList.add(scaleYAnimator);
         
            final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
            alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
            alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
            alphaAnimator.setStartDelay(i * rippleDelay);
            alphaAnimator.setDuration(rippleDurationTime);
            animatorList.add(alphaAnimator);
        }

        animatorSet.playTogether(animatorList);
    }

    private class RippleView extends View{

        public RippleView(Context context) {
            super(context);
            this.setVisibility(View.INVISIBLE);
        }

        @Override
        protected void onDraw(Canvas canvas) {
       
            int radius=(Math.min(getWidth(),getHeight()))/2;
            canvas.drawCircle(radius,radius,radius-rippleStrokeWidth,paint);
        }
    }

    public void startRippleAnimation(){
   
        if(!isRippleAnimationRunning()){
       
            for(RippleView rippleView:rippleViewList){
                rippleView.setVisibility(VISIBLE);
            }
         
            animatorSet.start();
            animationRunning=true;
        }
    }

    public void stopRippleAnimation(){
   
        if(isRippleAnimationRunning()){
            animatorSet.end();
            animationRunning=false;
        }
    }

    public boolean isRippleAnimationRunning(){
   
        return animationRunning;
    }
}
...................................................................................................................................................................

Step 4. Create activity_main inside res/layout folder.....

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:id="@+id/ScrollView1"
            android:background="@drawable/background"
             >

            <com.webnetware.view.RippleBackground
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="-4dip"
                app:rb_color="@color/one_backcolor"
                app:rb_duration="3000"
                app:rb_radius="32dp"
                app:rb_rippleAmount="1"
                app:rb_scale="14" >

                 

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:contentDescription="@null"
                    android:src="@drawable/forword_arrow" />
            </com.webnetware.view.RippleBackground>
        </RelativeLayout>
...................................................................................................................................................................
        
    
Step 5. create MainActivity java class inside src/ folder
        
    MainActivity.xml
..................................................................................................................................................................


import java.util.ArrayList;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;

import com.webnetware.singingbowl.R;
import com.webnetware.view.RippleBackground;

public class Splash_ScreenActivity extends Activity{
RippleBackground rippleBackground;
ImageView image;
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
 
super.onCreate(savedInstanceState);
setContentView(R.layout.term_and_activity);
rippleBackground=(RippleBackground)findViewById(R.id.content);
image = (ImageView) findViewById(R.id.imageView);
rippleBackground.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
rippleBackground.startRippleAnimation();
foundDevice(image);
  new Handler().postDelayed(new Runnable() {
   
    @Override
    public void run() {  
    rippleBackground.stopRippleAnimation();;  
     
        }  
         }, 3000);  
}
});
..................................................................................................................................................................

first screen without onClick.


second,when we are click on layout.


Read more

 The ImageView design in multiple Shape In android .

In this blog we will implement multiple ImageView Shape xml class in android.

activity_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"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/profile"
        android:padding="30dp"
        android:background="@drawable/image_ovalshape"
        android:scaleType="fitXY" />

</LinearLayout>
...................................................................................................................................................................


Imaige view in Oval shape xml .show view.



image_ovalshape.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="oval">
   
  <gradient 
    android:type="radial"
    android:gradientRadius="20"
    android:centerX=".6"
    android:centerY=".35"
    android:startColor="#a6cded"
    android:endColor="#a6cded" />
  
  <size 
    android:width="100dp"
    android:height="100dp"/>
</shape>
...................................................................................................................................................................

ImageView in rectangle shape.


image_racshape.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="15dp">
 <solid android:color="@color/gray"/>

    <corners
     android:bottomRightRadius="0dp"
     android:bottomLeftRadius="0dp"
     android:topLeftRadius="10dp"
     android:topRightRadius="10dp"/>

  <stroke android:width="2dip" android:color="#dce0e2" />  
</shape>
...................................................................................................................................................................
ImageView In Ring Shape.



image_ringshape.xml.
...................................................................................................................................................................

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <stroke
        android:width="3dp"
        android:color="#776da8" />

    <corners
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />

</shape>.
...................................................................................................................................................................

ImageView in Border View in Oval hsape.

border_ovalshape.xml.
..................................................................................................................................................................
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="#a6cded" />

    <stroke
        android:width="7dp"
        android:color="#776da8" />

    <corners
        android:bottomLeftRadius="100dp"
        android:bottomRightRadius="100dp"
        android:topLeftRadius="100dp"
        android:topRightRadius="100dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />

</shape>
...................................................................................................................................................................

ImageView In Rounded Shape.


rounded_imageview.xml.
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="15dp">
 <solid android:color="#e5d41b"/>

    <corners
     android:bottomRightRadius="20dp"
     android:bottomLeftRadius="20dp"
     android:topLeftRadius="20dp"
     android:topRightRadius="20dp"/>

  <stroke android:width="7dip" android:color="#32c24d" />  
</shape>
................................................................................................................................................................


ImageView In Border With transparent Background.


border_transperent.xml.
...................................................................................................................................................................

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

    <solid android:color="@color/transparent" />

    <stroke
        android:width="4dp"
        android:color="#ffffff" />

    <padding
        android:bottom="1dp"
        android:left="1dp"
        android:right="1dp"
        android:top="1dp" />

</shape>
...................................................................................................................................................................


ImageView In Border used two or three color in boder gradient xml class.

border.xml.
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <gradient
                android:angle="90"
                android:centerColor="@color/light_orange"
                android:endColor="@color/abs__background_holo_dark"
                android:startColor="@color/light_orange" />
        </shape>
    </item>
    <item
        android:bottom="6dp"
        android:left="3dp"
        android:right="3dp"
        android:top="2dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/purple_green" />
        </shape>
    </item>

</layer-list>
...................................................................................................................................................................


 try ...
Read more

Android Custom Slider Menu with Navigation Drawer ?

In this blog explain how to implement Slider Menu in android.






                                                                  ic_drawer icon






Step1.create string class inside res/value/string.xml. i required some string variable in slider listview item name and icon .
................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <string name="profile">Profile Name</string>
    <string name="view_Profile">View Profile</string>
    <string name="action_search">Sarch</string>  
    <string name="action_refresh">Refresh</string>
    <string name="app_name">Home</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
    <string name="drawer_open">Open navigation drawer</string>
    <string name="drawer_close">Close navigation drawer</string>
 
    <!-- Nav Drawer Menu Items -->
    <string-array name="nav_drawer_items">
        <item>Home</item>
        <item>Quick Query</item>
        <item>Share App</item>
        <item>About</item>
        <item>Term &amp; Coditions</item>
        <item>Help</item>
    </string-array>
    <array name="nav_drawer_icons">
        <item>@drawable/home</item> <!-- home -->
        <item>@drawable/quick_query</item> <!-- Quick Query -->
        <item>@drawable/share</item> <!-- Share App -->
        <item>@drawable/about</item> <!-- About -->
        <item>@drawable/term_condition</item> <!-- Term &amp; Coditions -->
        <item>@drawable/help</item> <!-- Help -->  
    </array>  
    <string name="desc_list_item_icon">Item Icon</string>
</resources>


Step 2.Create a color class inside res/value/color.xml

color.xml.
..................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="list_background_pressed">#2d596f</color>
    <color name="list_background">#cee8ef</color>
    <color name="list_divider">#949696</color>   
    <color name="list_item_title">#ffffff</color>    
    <color name="title_backgroundcolor">#52B9E6</color>   
    <color name="background_holo_light">#fff3f3f3</color>  
    <color name="black">#000000</color>     
    <color name="light_green">#3eb74e</color>
    <color name="light_purple">#8c61b3</color>
    <color name="light_orange">#ffb500</color>
    <color name="light_cyan">#00BCD4</color>
    <color name="white">#ffffff</color>
    <color name="purple_">#533A71</color>
    <color name="purple_green">#98a834</color>

</resources>


Step 3 Create activity_main class inside rec/layout/ folder.Here used Navigation drawer (DrawerLayout ) open your layout file.

 activity_main.xml.
.................................................................................................................................................................




<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
        android:isScrollContainer="true" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:background="@color/purple_green"
                android:gravity="center"
                android:orientation="vertical"
                android:padding="13dp" >

                <EditText
                    android:id="@+id/textView1"
                    android:layout_width="fill_parent"
                    android:layout_height="40dp"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginStart="15dp"
                    android:layout_marginTop="18dp"
                    android:background="@drawable/border"
                    android:drawableLeft="@drawable/location_marker"
                    android:drawableStart="@drawable/location_marker"
                    android:gravity="center|start"
                    android:hint="@string/loaction"
                    android:inputType="text"
                    android:paddingLeft="5dp"
                    android:textColor="@color/white"
                    android:textColorHint="@color/halka_white" >

                    <requestFocus />
                </EditText>

                <EditText
                    android:id="@+id/searchView1"
                    android:layout_width="fill_parent"
                    android:layout_height="40dp"
                    android:layout_marginBottom="18dp"
                    android:layout_marginLeft="15dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginStart="15dp"
                    android:layout_marginTop="4dp"
                    android:background="@drawable/border"
                    android:drawableLeft="@drawable/search"
                    android:drawableStart="@drawable/search"
                    android:gravity="center|start"
                    android:hint="@string/search_category"
                    android:inputType="text"
                    android:paddingLeft="5dp"
                    android:textColor="@color/white"
                    android:textColorHint="@color/halka_white" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="@color/abs__background_holo_light"
                android:orientation="vertical" >

                <GridView
                    android:id="@+id/gridView_business_item"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:numColumns="3"
                    android:scrollbars="none" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

    <!-- The navigation drawer -->

    <RelativeLayout
        android:id="@+id/drawerPane"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="start" >

        <!-- Profile Box -->

        <RelativeLayout
            android:id="@+id/profileBox"
            android:layout_width="match_parent"
            android:layout_height="130dp"
            android:background="@color/light_orange"
            android:padding="8dp" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="42dp"
                android:layout_centerVertical="true"
                android:layout_marginLeft="15dp"
                android:layout_marginStart="15dp"
                android:layout_toEndOf="@+id/avatar"
                android:layout_toRightOf="@+id/avatar"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/userName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/profile"
                    android:textColor="#fff"
                    android:textSize="16sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/desc"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginTop="4dp"
                    android:text="@string/view_Profile"
                    android:textColor="#fff"
                    android:textSize="12sp" />
            </LinearLayout>

            <ImageView
                android:id="@+id/avatar"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:background="@drawable/image_in_ring"
                android:contentDescription="@null"
                android:padding="10dp"
                android:scaleType="fitXY"
                android:src="@drawable/profile" />
        </RelativeLayout>

        <!-- List of Actions (pages) -->

        <ListView
            android:id="@+id/list_slidermenu"
            android:layout_width="280dp"
            android:layout_height="match_parent"
            android:layout_below="@+id/profileBox"
            android:layout_gravity="start"
            android:background="#ffffff"
            android:choiceMode="singleChoice"
            android:divider="@color/list_divider"
            android:dividerHeight="1dp"
            android:listSelector="@drawable/list_selector" />
    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>



Step 4.Creating a Custom list View Adapter

First, you can create some gradiend xml as per Requirment for example 
1.list_item_bg_normal.xml, 
2list_item_bg_pressed.xml, 
3 list_selectore.xml.,
4imaige_in_ring.xml. 
 show below and explain how why we used these gradient xml ..


list_item_bg_normal.xml.
..................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="@color/white"
      android:endColor="@color/white"
      android:angle="90" />
</shape>



list_item_bg_pressed.xml
...................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle">
    <gradient
      android:startColor="@color/background_holo_light"
      android:endColor="@color/background_holo_light"
      android:angle="90" />

</shape>


list_selectore.xml.
...................................................................................................................................................................

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
     <item android:drawable="@drawable/list_item_bg_normal" android:state_activated="false"/>
     <item android:drawable="@drawable/list_item_bg_pressed" android:state_pressed="true"/>
     <item android:drawable="@drawable/list_item_bg_pressed" android:state_activated="true"/>
</selector>

imaige_in_ring.xml.
..................................................................................................................................................................
<?xml version="1.0" encoding="utf-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:shape="oval">
   
  <gradient 
    android:type="radial"
    android:gradientRadius="20"
    android:centerX=".6"
    android:centerY=".35"
    android:startColor="#FFFF00"
    android:endColor="#FFFF99" />
  
  <size 
    android:width="100dp"
    android:height="100dp"/>
</shape>



Step 5. Creating a List row inside res/layout/drawer_list_item.xml ..

drawer_list_item.xml.
the class used in adapter class
...................................................................................................................................................................


<?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="60dp"
    android:background="@drawable/list_selector" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:scaleType="fitXY"
        android:contentDescription="@string/desc_list_item_icon"
        android:src="@drawable/home" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_centerVertical="true"
        android:layout_toEndOf="@id/icon"
        android:layout_toRightOf="@+id/icon"
        android:gravity="center|start"
        android:text="hello"
        android:textColor="@color/black" />

</RelativeLayout>

Step 6. Create NavDrawerListAdapter class inside src/ folder...

NavDrawerListAdapter .java.
...................................................................................................................................................................


import java.util.ArrayList;
import com.webnetware.businesstickmyad.R;
import com.webnetware.services.NavDrawerItem;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

@SuppressLint("InflateParams")
public class NavDrawerListAdapter extends BaseAdapter {

private Context context;
private ArrayList<NavDrawerItem> navDrawerItems;

public NavDrawerListAdapter(Context context,
ArrayList<NavDrawerItem> navDrawerItems) {
this.context = context;
this.navDrawerItems = navDrawerItems;
}

@Override
public int getCount() {
return navDrawerItems.size();
}

@Override
public Object getItem(int position) {
return navDrawerItems.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.drawer_list_item, null);
}

ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
 
imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
txtTitle.setText(navDrawerItems.get(position).getTitle());

 
 

return convertView;
}
}

Step 6. Create MainActivity class inside src folder..

MainActivity .java
...................................................................................................................................................................

 package com.webnetware.businesstickmyad;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.webnetware.adapter.CustomGridAdapter;
import com.webnetware.adapter.NavDrawerListAdapter;
import com.webnetware.services.NavDrawerItem;

@SuppressWarnings("deprecation")
public class MainActivity extends Activity implements   ActionBar.OnNavigationListener{

private DrawerLayout mDrawerLayout;

RelativeLayout mDrawerPane;
 
 
   private ListView mDrawerList;
   private ActionBarDrawerToggle mDrawerToggle;
 
private ActionBar actionBar;

   Button postAnAds,btnlocation;
   GridView gridView;
   TextView getlocation;
 

   String mTitle="";
 
   boolean visible=true;
 
   private String[] navMenuTitles;
   private TypedArray navMenuIcons;

   private ArrayList<NavDrawerItem> navDrawerItems;
   private NavDrawerListAdapter adapter;
 
 
 

   @SuppressLint("NewApi")
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
actionBar = getActionBar();
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_main);
     
     


mTitle = (String) getTitle();


navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

   // Populate the Navigtion Drawer with options
mDrawerPane = (RelativeLayout) findViewById(R.id.drawerPane);


mDrawerList = (ListView) findViewById(R.id.list_slidermenu);

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, R.string.app_name, R.string.app_name) {
public void onDrawerClosed(View view) {

invalidateOptionsMenu();
}

public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("");
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.closeDrawer(mDrawerPane);

navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);

navDrawerItems = new ArrayList<NavDrawerItem>();

     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1)));
     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
     
       navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
     
      // navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(6, -1)));
      // navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(7, -1)));

     
       navMenuIcons.recycle();

   
       this.adapter = new NavDrawerListAdapter(getApplicationContext(),navDrawerItems);
       this.mDrawerList.setAdapter(adapter);
 
       mDrawerLayout.setDrawerListener(mDrawerToggle);
       mDrawerList.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long id) {
switch (position) {
case 0:
Intent intenthome =new Intent(MainActivity.this, MainActivity.class);
           startActivity(intenthome);
break;
case 1:
Intent Quickquiry_Activity =new Intent(MainActivity.this,Quickquiry_Activity.class);
        startActivity(Quickquiry_Activity);
break;
case 2:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
                 shareIntent.setType("text/plain");
                 shareIntent.putExtra(Intent.EXTRA_TEXT, "Click On,http://tickmyad.com/download.aspx");
                 startActivity(Intent.createChooser(shareIntent, "Share"));
               overridePendingTransition(R.anim.leftoright,R.anim.rihgttoleft);
break;
case 3:
Intent About_Activity =new Intent(MainActivity.this,About_Activity.class);
        startActivity(About_Activity);
break;
case 4:
Intent TermAndCondition =new Intent(MainActivity.this,TermAndCondition.class);
        startActivity(TermAndCondition);
break;
case 5:
Intent HelpActivity =new Intent(MainActivity.this,HelpActivity.class);
        startActivity(HelpActivity);
break;
default:
break;
}
}
});

      //  CustomGridAdapter adapter = new CustomGridAdapter(MainActivity.this, web, imageId);
            // gridView = (GridView)findViewById(R.id.gridView_business_item);
         
         //     gridView.setVerticalScrollBarEnabled(false);
        //    gridView.setAdapter(adapter);
        //  gridView.setOnItemClickListener(new OnItemClickListener() {

      // @Override
                 //public void onItemClick(AdapterView<?> arg0, View view, int possition,
      // long id) {
     
      //Intent Buslist_activity=new Intent(MainActivity.this,BusinessList_Activity.class);
      //Buslist_activity.putExtra("BusinessName",web[possition]);    
      //startActivity(Buslist_activity);
      //overridePendingTransition(R.anim.leftoright,R.anim.rihgttoleft);
     
     
      //}
      //});

       mDrawerLayout.closeDrawer(mDrawerPane);

   }
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {

return false;
}

   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
       getMenuInflater().inflate(R.menu.main, menu);
   
       return true;
   }
 
 

   @Override
   protected void onPostCreate(Bundle savedInstanceState) {
       super.onPostCreate(savedInstanceState);
   
       mDrawerToggle.syncState();
   }
 
@Override
   public boolean onOptionsItemSelected(MenuItem item) {  
         if(item.getItemId()==R.id.action_search){
         return true;
         }
         if(item.getItemId()==R.id.action_refresh){
       
  return true;
         }
       if (mDrawerToggle.onOptionsItemSelected(item)) {
         return true;
       }
       return super.onOptionsItemSelected(item);
   }

@Override
   public boolean onPrepareOptionsMenu(Menu menu) {
   
       return super.onPrepareOptionsMenu(menu);
   }
}



Step 7. Create slider Menu activity class ....

test_activity.xml.
Create a UI design as per require.
..................................................................................................................................................................

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

     

</LinearLayout>


Quickquiry_Activity .java
...................................................................................................................................................................
public class Quickquiry_Activity extends Activity {


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
}
}

About_Activity.java
...................................................................................................................................................................
public class About_Activity extends Activity {


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
}
}
TermAndCondition.java
...................................................................................................................................................................
public class TermAndCondition extends Activity {


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
}
}
HelpActivity.java
...................................................................................................................................................................
public class HelpActivity extends Activity {


@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.test_activity);
}
}



try this code......






Read more