Monday, April 23, 2012

Android: Saving cache files on external storage.

Hi, If you want to save some files on external storage and you want those files to be removed on application un-installation, then do as the documentation says ;) If you're using API Level 8 or greater, use getExternalCacheDir() to open a File that represents the external storage directory where you should save cache files. If the user uninstalls your application, these files will be automatically...

Tuesday, April 17, 2012

Android: Create an image Viewer using ViewPager.

Hi, This post is for those guys digging the Internet trying to find out how to create an image viewer. And I managed to do that using ViewPager. First, you'll need to download the support package using the SDK manager. Then, set up the project to use the library, as mentioned here. OR, if you use Eclipse, you can simply right click your project > Android Tools > Add Compatibility Library. I'll...

Sunday, April 15, 2012

Android: Create a simple horizontal image list.

Hi, In this post we'll create our horizontal image List using HorizontalScrollView. First,  create the layout. main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <HorizontalScrollView...

Friday, April 6, 2012

Android: Layout params programmatically.

Hi, This is a concise tip. To set the width, height and gravity for -say - a LinearLayout, do the following: LinearLayout linearLayout = (LinearLayout)findViewById(R.id.movieDetails_linearLayout); linearLayout.setLayoutParams(new ParentView.LayoutParams(LayoutParams.WRAP_CONTENT , LayoutParams.WRAP_CONTENT,Gravity.CENTER_HORIZONTAL)); Note...