Learn how to use a Fragment with an Activity

In the last Tutorial you learnt about Fragments and why to use them.

Using a Fragment with an Activity is pretty simple to start with. You need to add the fragment attribute to the activity layout file. Follow the short video to know how to do this.

Refer to the code here

Android Basics – Learn how to handle Clicks in a ListActivity using onListItemClick

By now you should be familiar with a ListActivity and how to use this to display items.

So what happen’s when a user clicks on an item. How can you handle that ?

The good news is that you don’t need to use an EventListener. You can simply override onListItemClick method.

@Override
public void onListItemClick(ListView listView, View itemView, int position, long id){
    //Implement your Logic
    //Here id param is id of the item clicked. It can also be the DB unique id
}

Source code is available here

Android Basics – Learn how to use Adapter with ListView

In the last Post you learnt about the ListActivity class. In this Tutorial I want to introduce you to Adapters and how to use them with ListView.

Adapters are used to bind or connect View with Data Source. Now a data source can be an array, a database or a web service.

An ArrayAdapter enables us to work with Arrays. Creating one is pretty simple.

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, colors);

You can follow along with me in the Video above to understand about Adapters.

Source code can be found here

Android Basics – Learn how to use a ListActivity to display and manage a List of Items

 

In the last Post you got familiar with using a ListView to display a list of items which came from a static String Array.

You can also accomplish the same using a ListActivity.

Why use ListActivity ?

A ListActivity class is quite useful as you don’t need to create a Layout file.

You have the option to create your own Layout file, but it’s not mandatory.

Also you don’t need to create an Event Listener. In order to use the ListActivity you will need to extend this class.

public class ScrollingActivity extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}

Follow the Video in which I will guide you to create a new ListActivity to display the items.

Source Code is available here

Robin, the newest Android Smartphone, will solve the Storage Problem and will Learn from your usage patterns

Introducing Robin, the first Android phone that makes running out of space history.

That’s what the official website promises.

The phone is a mid-range, but capable Android phone from a small, independent startup led by ex-Google and HTC executives and engineers.

It goes on sale at the company’s website, starting today, 32GB unlocked for $399. This also gets you 100GB of Cloud Storage.

The website also mentions that the Smartphone Learns what you use, and it’s designed for fast OS updates.

You can explore more and buy at https://www.nextbit.com/collections/all

Android Basics – Learn about Event Listeners. How ListView Item Click Works ?

In the last Article you learnt about ListView and how it can be used to display a List of items.

So the list of items is ready, what’s next ?

Don’t you think the user should be able to do something with that. Like view the details of an item.

To enable the App to perform some activity when an item is clicked you need to use an onItemClickListener.

Source Code is available here