Saturday 14 December 2013

Custom Toast

1) in Activity.java
==============
final View toastView = getLayoutInflater().inflate(
R.layout.custom_toast,(ViewGroup) findViewById(R.id.toastLayout));
ImageView imageView = (ImageView) toastView
.findViewById(R.id.image);
imageView.setImageResource(R.drawable.ic_info);

// imageView.setBackgroundDrawable(bitmapDrawable);
TextView textView = (TextView) toastView.findViewById(R.id.text);
textView.setText("Take a Clear photo of the Ticket");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
toast = new Toast(HomeActivity.this);
toast.setGravity(Gravity.TOP, 0, 100);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(toastView);
toast.show();
}
}, 2000);

2) custom_toast.xml
==============
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toastLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@layout/roundborder"
    android:orientation="horizontal"
    android:padding="10dp" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="1dp" />

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:layout_marginRight="4dp"
        android:gravity="center"
        android:paddingLeft="5dip"
        android:text="Take a clear photo of the Ticket"
        android:textColor="#FFF"
        android:textSize="16dip" />

</LinearLayout>

Friday 13 December 2013

RSS Feed Reader

1)MainActivity.java
==============
package com.example.rssfeed;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import nl.matshofman.saxrssreader.RssFeed;
import nl.matshofman.saxrssreader.RssItem;
import nl.matshofman.saxrssreader.RssReader;
import org.xml.sax.SAXException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends Activity {
private TextView txtTitle;

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

txtTitle = (TextView)findViewById(R.id.txtTitle);

if (android.os.Build.VERSION.SDK_INT > 9) {
   StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
   StrictMode.setThreadPolicy(policy);
}

URL url = null;
try {
url = new URL("http://www.vogella.com/article.rss");
} catch (MalformedURLException e) {
e.printStackTrace();
}
RssFeed feed = null;
try {
feed = RssReader.read(url);
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

ArrayList<RssItem> rssItems = feed.getRssItems();
for(RssItem rssItem : rssItems) {
   Log.i("RSS Reader", rssItem.getTitle());
   txtTitle.setText(rssItem.getTitle());
}
}
}
2)Download library from

3)Manifest Permissions
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

ShowMultipleFileDownloadProgression

1) Create class CustomListViewAdapter.java
==============================
package com.example.showdownloadprogression;

import java.util.List;
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;

public class CustomListViewAdapter extends BaseAdapter {

   Context context;
   List<RowItem> rowItems;

   public CustomListViewAdapter(Context context, List<RowItem> items) {
       this.context = context;
       this.rowItems = items;
   }

   private class ViewHolder {
       ImageView imageView;
   }

   public int getCount() {
       return rowItems.size();
   }

   public Object getItem(int position) {
       return rowItems.get(position);
   }

   public long getItemId(int position) {
       return 0;
   }

   public View getView(int position, View convertView, ViewGroup parent) {
       ViewHolder holder = null;
       LayoutInflater mInflater = (LayoutInflater) context
               .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
       if (convertView == null) {
           convertView = mInflater.inflate(R.layout.list_item, null);
           holder = new ViewHolder();
           holder.imageView = (ImageView) convertView
                   .findViewById(R.id.thumbnail);
           convertView.setTag(holder);
       } else {
           holder = (ViewHolder) convertView.getTag();
       }
       RowItem rowItem = (RowItem) getItem(position);
       holder.imageView.setImageBitmap(rowItem.getBitmapImage());
       return convertView;
   }
}

2) Create class FileUtils.java
====================
package com.example.showdownloadprogression;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class FileUtils {

    public static void close(InputStream stream) {
        if(stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(OutputStream stream) {
        if(stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


3) Create class MainActivity.java
=======================
package com.example.showdownloadprogression;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ListView;
public class MainActivity extends Activity {
    ProgressDialog progressDialog;
    CustomListViewAdapter listViewAdapter;
    ListView listView;
    public static final String URL =
        "http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png";
    public static final String URL1 =
        "http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png";
    public static final String URL2 =
        "http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            listView = (ListView) findViewById(R.id.imageList);
        /*Creating and executing background task*/
        GetXMLTask task = new GetXMLTask(this);
        task.execute(new String[] { URL, URL1, URL2 });
        progressDialog = new ProgressDialog(this);
        progressDialog.setTitle("In progress...");
        progressDialog.setMessage("Loading...");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setIndeterminate(false);
        progressDialog.setMax(100);
        progressDialog.setIcon(R.drawable.arrow);
        progressDialog.setCancelable(true);
        progressDialog.show();
    }
// 
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.activity_main, menu);
//        return true;
//    }
    private class GetXMLTask extends AsyncTask<String, Integer, List<RowItem>> {
        private Activity context;
        List<RowItem> rowItems;
        int noOfURLs;
        public GetXMLTask(Activity context) {
            this.context = context;
        }
        @Override
        protected List<RowItem> doInBackground(String... urls) {
            noOfURLs = urls.length;
            rowItems = new ArrayList<RowItem>();
            Bitmap map = null;
            for (String url : urls) {
                map = downloadImage(url);
                rowItems.add(new RowItem(map));
            }
            return rowItems;
        }
        private Bitmap downloadImage(String urlString) {
            int count = 0;
            Bitmap bitmap = null;
            URL url;
            InputStream inputStream = null;
            BufferedOutputStream outputStream = null;
            try {
                url = new URL(urlString);
                URLConnection connection = url.openConnection();
                int lenghtOfFile = connection.getContentLength();
                inputStream = new BufferedInputStream(url.openStream());
                ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
                outputStream = new BufferedOutputStream(dataStream);
                byte data[] = new byte[512];
                long total = 0;
                while ((count = inputStream.read(data)) != -1) {
                    total += count;
                    /*publishing progress update on UI thread.
                    Invokes onProgressUpdate()*/
                    publishProgress((int)((total*100)/lenghtOfFile));
                    // writing data to byte array stream
                    outputStream.write(data, 0, count);
                }
                outputStream.flush();
                BitmapFactory.Options bmOptions = new BitmapFactory.Options();
                bmOptions.inSampleSize = 1;
                byte[] bytes = dataStream.toByteArray();
                bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length,bmOptions);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                FileUtils.close(inputStream);
                FileUtils.close(outputStream);
            }
            return bitmap;
        }
        protected void onProgressUpdate(Integer... progress) {
            progressDialog.setProgress(progress[0]);
            if(rowItems != null) {
                progressDialog.setMessage("Loading " + (rowItems.size()+1) + "/" + noOfURLs);
            }
       }
       @Override
       protected void onPostExecute(List<RowItem> rowItems) {
        listViewAdapter = new CustomListViewAdapter(context, rowItems);
        listView.setAdapter(listViewAdapter);
        progressDialog.dismiss();
       }    
    }
}

4) Create class RowItem.java
====================
package com.example.showdownloadprogression;

import android.graphics.Bitmap;

public class RowItem {
 
    private Bitmap bitmapImage;
    public RowItem(Bitmap bitmapImage) {
        this.bitmapImage =  bitmapImage;
    }
    public Bitmap getBitmapImage() {
        return bitmapImage;
    }
    public void setBitmapImage(Bitmap bitmapImage) {
        this.bitmapImage = bitmapImage;
    }
}

5)activity_main.xml
=============
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >
    <ListView
        android:id="@+id/imageList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>

6) list_item.xml
============
<?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="wrap_content"
    android:orientation="vertical"
    android:padding="10dp" >
    <ImageView
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

7) in values-v11 style.xml
=================
<resources>

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!-- API 11 theme customizations can go here. -->
    </style>
</resources>

8) in values-v14 style.xml
==================
<resources>

  <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>
</resources>

9) Don't forget to give permission of "Internet" & "Access_Network_State"




Saturday 23 November 2013

Shake Animation Edittext

1. Activity Class:




package com.mukesh.shakeanimation;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Toast;

public class MainActivity extends Activity implements View.OnClickListener {

 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  View loginButton = findViewById(R.id.login);
  loginButton.setOnClickListener(this);
 }

 public void onClick(View v) {
  Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake);
     findViewById(R.id.pw).startAnimation(shake);
     Toast.makeText(this, "Wrong Password", Toast.LENGTH_SHORT).show();
 }

}


2) activity_main.xml 




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:background="@drawable/blue_gradient"

    android:orientation="vertical"

    android:padding="10dip" >



    <TextView

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="10dip"

        android:text="Please enter your password:"

        android:textColor="@android:color/white"

        android:textStyle="bold" />



    <EditText

        android:id="@+id/pw"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:clickable="true"

        android:password="true"

        android:singleLine="true" />



    <Button

        android:id="@+id/login"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:background="@drawable/btn_active_pressed"

        android:padding="5dp"

        android:text="Login"

        android:textColor="@android:color/white"

        android:textStyle="bold" />



</LinearLayout>

3. res/anim/shake.xml 

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromXDelta="0"
    android:interpolator="@anim/cycle_7"
    android:toXDelta="10" />

4. res/anim/cycle_7.xml 

<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
    android:cycles="7" />


Friday 22 November 2013

Paging in android

Pagination of screen in Android.

There are different Pagination is available in android. you can used as per your requirements.

CIrcle Flow indicator.
 
Title Flow indicator.
Different view Flow.
AsyncDataLoading.

Slid Menu Bar Example

Side Menu Bar in Android.

Now a days this is most important feature in android, every one want to make easy interface with minimum user interface, Android provide Side menu for easy user interface, enjoy code.



horz_sidemenu_activity_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<com.hb.example.HorizontalSideScrollViewxmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="0px"
    android:background="#00ffffff"
    android:fadingEdge="none"
    android:fadingEdgeLength="0px"
    android:padding="0px"
    android:scrollbars="none" >

    <LinearLayout
        android:id="@+id/top"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="0px"
        android:background="#ffffffff"
        android:orientation="horizontal"
        android:padding="0px" >
    </LinearLayout>

</com.hb.example.HorizontalSideScrollView>


mainapplication_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/app"
    android:layout_width="1dp"
    android:layout_height="1dp"
    android:layout_margin="2dp"
    android:background="#ffffff"
    android:orientation="vertical"
    android:padding="2dp" >

    <LinearLayout
        android:id="@+id/tabBar"
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:background="#F6CE1E"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/BtnSlide"
            android:layout_width="40dip"
            android:layout_height="wrap_content"
            android:layout_margin="0px"
            android:background="@drawable/left"
            android:padding="0px" />

        <View
            android:layout_width="2dip"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dip"
            android:layout_marginRight="15dip"
            android:background="#000000" >
        </View>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="Company Name"
            android:textColor="#000000"
            android:textSize="8pt" />
    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="2dip"
        android:background="#000000" >
    </View>

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#25B5F1"
        android:cacheColorHint="@android:color/transparent"
        android:divider="#FFFFFF"
        android:dividerHeight="2dip"
        android:paddingTop="10dip" >
    </ListView>

</LinearLayout>



side_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/menu"
    android:layout_width="1dp"
    android:layout_height="1dp"
    android:background="#000000"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/tabBar"
        android:layout_width="fill_parent"
        android:layout_height="60dip"
        android:background="#F6CE1E"
        android:gravity="center"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="10dip"
            android:text="Mobile Name"
            android:textColor="#000000"
            android:textSize="8pt" />
    </LinearLayout>

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#25B5F1"
        android:cacheColorHint="@android:color/transparent"
        android:divider="#FFFFFF"
        android:dividerHeight="2dip"
        android:scrollbars="none" >
    </ListView>

</LinearLayout>


HorizontalSideScrollView:
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.HorizontalScrollView;

public class HorizontalSideScrollView extends HorizontalScrollView
{
      public HorizontalSideScrollView(Context context, AttributeSet attrs, intdefStyle)
      {
            super(context, attrs, defStyle);
            init(context);
      }

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

      public HorizontalSideScrollView(Context context)
      {
            super(context);
            init(context);
      }

      void init(Context context)
      {
            // remove the fading as the HSV looks better without it
            setHorizontalFadingEdgeEnabled(false);
            setVerticalFadingEdgeEnabled(false);
      }

      /**
       * @param children
       *            The child Views to add to parent.
       * @param scrollToViewIdx
       *            The index of the View to scroll to after initialisation.
       * @param sizeCallback
       *            A SizeCallback to interact with the HSV.
       */
      public void initViews(View[] children, int scrollToViewIdx, SizeCallback sizeCallback)
      {
            // A ViewGroup MUST be the only child of the HSV
            ViewGroup parent = (ViewGroup) getChildAt(0);

            // Add all the children, but add them invisible so that the layouts are calculated, but you can't see the Views
            for (int i = 0; i < children.length; i++)
            {
                  children[i].setVisibility(View.INVISIBLE);
                  parent.addView(children[i]);
            }

            // Add a layout listener to this HSV
            // This listener is responsible for arranging the child views.
            OnGlobalLayoutListener listener = newMyOnGlobalLayoutListener(parent, children, scrollToViewIdx, sizeCallback);
            getViewTreeObserver().addOnGlobalLayoutListener(listener);
      }

      @Override
      public boolean onTouchEvent(MotionEvent ev)
      {
            // Do not allow touch events.
            return false;
      }

      @Override
      public boolean onInterceptTouchEvent(MotionEvent ev)
      {
            // Do not allow touch events.
            return false;
      }

      /**
       * An OnGlobalLayoutListener impl that passes on the call to onGlobalLayout to a SizeCallback, before removing all the Views
       * in the HSV and adding them again with calculated widths and heights.
       */
      class MyOnGlobalLayoutListener implements OnGlobalLayoutListener
      {
            ViewGroup parent;
            View[] children;
            int scrollToViewIdx;
            int scrollToViewPos = 0;
            SizeCallback sizeCallback;

            public MyOnGlobalLayoutListener(ViewGroup parent, View[] children,int scrollToViewIdx, SizeCallback sizeCallback)
            {
                  this.parent = parent;
                  this.children = children;
                  this.scrollToViewIdx = scrollToViewIdx;
                  this.sizeCallback = sizeCallback;
            }

            @Override
            public void onGlobalLayout()
            {    

                  final HorizontalSideScrollView me = HorizontalSideScrollView.this;

                  // The listener will remove itself as a layout listener to the HSV
                  me.getViewTreeObserver().removeGlobalOnLayoutListener(this);

                  // Allow the SizeCallback to 'see' the Views before we remove them and re-add them.
                  // This lets the SizeCallback prepare View sizes, ahead of calls to SizeCallback.getViewSize().
                  sizeCallback.onGlobalLayout();

                  parent.removeViewsInLayout(0, children.length);

                  final int w = me.getMeasuredWidth();
                  final int h = me.getMeasuredHeight();

                  // System.out.println("w=" + w + ", h=" + h);

                  // Add each view in turn, and apply the width and height returned by the SizeCallback.
                  int[] dims = new int[2];
                  scrollToViewPos = 0;
                  for (int i = 0; i < children.length; i++)
                  {
                        sizeCallback.getViewSize(i, w, h, dims);
                        // System.out.println("addView w=" + dims[0] + ", h=" + dims[1]);
                        children[i].setVisibility(View.VISIBLE);
                        parent.addView(children[i], dims[0], dims[1]);
                        if (i < scrollToViewIdx)
                        {
                              scrollToViewPos += dims[0];
                        }
                  }

                  // For some reason we need to post this action, rather than call immediately.
                  // If we try immediately, it will not scroll.
                  new Handler().post(new Runnable()
                  {
                        @Override
                        public void run()
                        {
                              me.scrollBy(scrollToViewPos, 0);
                        }
                  });
            }
      }

      /**
       * Callback interface to interact with the HSV.
       */
      public interface SizeCallback
      {
            /**
             * Used to allow clients to measure Views before re-adding them.
             */
            public void onGlobalLayout();

            /**
             * Used by clients to specify the View dimensions.
             *
             * @param idx
             *            Index of the View.
             * @param w
             *            Width of the parent View.
             * @param h
             *            Height of the parent View.
             * @param dims
             *            dims[0] should be set to View width. dims[1] should be set to View height.
             */
            public void getViewSize(int idx, int w, int h, int[] dims);
      }
}

HorzScrollSideMenuActivity:
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import com.hb.example.HorizontalSideScrollView.SizeCallback;

public class HorzScrollSideMenuActivity extends Activity
{
      HorizontalSideScrollView scrollView;
      View menuView;
      View applicationView;
      ImageView btnSlide;
      boolean menuOut = false;
      Handler handler = new Handler();
      int btnWidth;
      String[] cmpName=  {"HTC","i-Phone","Blackberry","Nokia","Samsung","Micromax","Spice","Relilence"};
      String[] mobilenm=  {"HTC-Desire X","i-Phone5","Tourch-9700","Lumia-9200","Ninja-A90","Ninja A-110"};
     
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
            super.onCreate(savedInstanceState);

            LayoutInflater inflater = LayoutInflater.from(this);
            scrollView = (HorizontalSideScrollView) inflater.inflate(R.layout.horz_sidemenu_activity_layoutnull);
            setContentView(scrollView);

            menuView = inflater.inflate(R.layout.side_menunull);
            applicationView = inflater.inflate(R.layout.mainapplication_layout,null);
            ViewGroup tabBar = (ViewGroup)applicationView.findViewById(R.id.tabBar);

            ListView listView = (ListView)applicationView.findViewById(R.id.list);
            ArrayAdapter< String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1cmpName);
            listView.setAdapter(adapter);
            ListView listView1 = (ListView) menuView.findViewById(R.id.list);
            ArrayAdapter< String> devSiteadapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1mobilenm);
            listView1.setAdapter(devSiteadapter);
            btnSlide = (ImageView) tabBar.findViewById(R.id.BtnSlide);
            btnSlide.setOnClickListener(newClickListenerForScrolling(scrollViewmenuView));

            final View[] children = new View[] { menuViewapplicationView };
            int scrollToViewIdx = 1;
            scrollView.initViews(children, scrollToViewIdx, newSizeCallbackForMenu(btnSlide));
            listView1.setOnItemClickListener(new OnItemClickListener()
            {

                  @Override
                  public void onItemClick(AdapterView<?> arg0, View arg1, intposition,
                              long arg3)
                  {
                        Toast.makeText(HorzScrollSideMenuActivity.this"Side Menu  Clicked Item  : "+mobilenm[position], Toast.LENGTH_SHORT).show();

                  }
            });
            listView.setOnItemClickListener(new OnItemClickListener()
            {

                  @Override
                  public void onItemClick(AdapterView<?> arg0, View arg1, intposition,
                              long arg3)
                  {
                        Toast.makeText(HorzScrollSideMenuActivity.this,"Clicked Item  : "+cmpName[position], Toast.LENGTH_SHORT).show();

                  }
            });
      }

      /**
       * Helper for examples with a HSV that should be scrolled by a menu View's width.
       */
      static class ClickListenerForScrolling implements OnClickListener
      {
            HorizontalScrollView scrollView;
            View menu;
            /**
             * Menu must NOT be out/shown to start with.
             */
            boolean menuOut = false;

            public ClickListenerForScrolling(HorizontalScrollView scrollView, View menu) {
                  super();
                  this.scrollView = scrollView;
                  this.menu = menu;
            }

            @Override
            public void onClick(View v)
            {
                  int menuWidth = menu.getMeasuredWidth();
                  // Ensure menu is visible
                  menu.setVisibility(View.VISIBLE);

                  if (!menuOut)
                  {
                        int left = 0;
                        scrollView.smoothScrollTo(left, 0);
                  } else
                  {
                        int left = menuWidth;
                        scrollView.smoothScrollTo(left, 0);
                  }
                  menuOut = !menuOut;
            }
      }

      /**
       * Helper that remembers the width of the 'slide' button, so that the 'slide' button remains in view, even when the menu is
       * showing.
       */
      static class SizeCallbackForMenu implements SizeCallback
      {
            int btnWidth;
            View btnSlide;

            public SizeCallbackForMenu(View btnSlide)
            {
                  super();
                  this.btnSlide = btnSlide;
            }

            @Override
            public void onGlobalLayout()
            {
                  btnWidth = btnSlide.getMeasuredWidth();
            }

            @Override
            public void getViewSize(int idx, int w, int h, int[] dims)
            {
                  dims[0] = w;
                  dims[1] = h;
                  final int menuIdx = 0;
                  if (idx == menuIdx)
                  {
                        dims[0] = w - btnWidth;
                  }
            }
      }
}