SMR's Android Blog

April 8, 2014

ListViews are one of the most used widgets in Android because of their customizability. Using swipe gestures on ListViews can be very useful to provide an easy to use, stunning UI and awesome UX.

We can use swipe gestures within eachListView item to allow the user to perform a particular action or change the UI of the ListView row item.

This tutorial will help you to implement a custom ListView which initially display some details in TextViews and; when the user swipes from Right to Left on a list item; few ImageButtons appear from the right direction and the details slide out to the left.

I will try do this without the usage of any external libraries or APIs. Using the stock widgets(Views) of android and some simple animation using XMLs.

How the ListView will look and behave?

How the project is organized?

/res/animfolder which contains the 4 animation files we will use for animations on swipes. The files inside this folder are self-explanatory.

list_row_item.xml is the layout for our custom ListView's row item.

MyGestureListener.java is a custom SimpleOnGestureListenerwhich will be used to perform defined gesture actions on each item of the ListView.

MyListAdapter.java is the custom BaseAdapterwhich will be used to display ListView's content.

MainActivity.java( activity_main.xml ) is the main layout of our project. It is just a normal Activity which contain a ListView.

Create a new project and create a new xml file named list_row_item.xml in the /res/layout folder.

Now create a folder named anim in the/resfolder of your project. As mentioned earlier this folder will be used to keep the animation files. After that you need to create the following four XML files in the/res/animfolder:

March 5, 2014

Today everyone wants to make their App as much socially integrated as possible. WhatsApp is the most popular messaging app available out there in the market but unfortunately WhatsApp does not provide any APIs for the integration of other apps. But most people want to enable their apps to send messages via Whatsapp ( i.e. directly; not via implicit intents or choosers).We all know that Whatsapp stores its contacts in the phone's contact book. Hence if the Whatsapp contacts are stored in the contact book then other apps should be able to view them. Whatsapp doesn't have its own Content Provider but because the contacts are stored in the phone then we should be able to view them with the help of ContactsContract content provider.Now different people may have different ways of accessing the Whatsapp contacts and there may be better ways of doing what I am trying to do but here is what I did to do the same.

How Whatsapp stores contacts in android phones?

First we will need the following permission in the AndroidManifest.xml in order to read these contacts:

<uses-permission android:name="android.permission.READ_CONTACTS" />I am showing all the Whatsapp contacts in a custom ListViewwith two TextViews. Touching on any item in this list view will open the chat thread for that contact.