Posts

Android Activity

Image
An Android activity is one screen of the Android app's user interface. In that way an Android activity is very similar to windows in a desktop application. An Android app may contain one or more activities, meaning one or more screens. The Android app starts by showing the main activity, and from there the app may make it possible to open additional activities. Activity Life Cycle Any Android activity goes through a certain life cycle during its life inside the Android app. This life cycle is illustrated here: When an Android app is first started the main activity is created. The activity then goes through 3 states before it is ready to serve the user: Created, started and resumed. If the main activity can open any other activities (screens) these activities will go through the same 3 states when they are opened. If an activity A opens another activity B, then activity A will be paused. This means that activity A goes into the paused state. When the user clicks ...

Getting Started With RecyclerView using CardView in Android

If you are interested in building an Android app that makes use of lists to display data, Android Lollipop features two new widgets to make your life easier, RecyclerView and CardView. Using these widgets, it is very easy to give your app a look and feel that conforms to the guidelines mentioned in Google's material design specification. Support Older Versions Add following dependencies to build.gradle compile 'com.android.support:cardview-v7:26.0.0-alpha1' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' Creating a CardView A CardView is a ViewGroup. Like any other ViewGroup, it can be added to your Activity or Fragment using a layout XML file. To create an empty CardView, you would have to add the following code to your layout XML as shown in the following snippet: <android.support.v7.widget.CardView         xmlns:card_view="http://schemas.android.com/apk/res-auto"         android:layout_width="match_parent" ...

Getting Started With Card View

If you are interested in building an Android app that makes use of lists to display data, Android Lollipop features new widget to make your life beutiful, CardView. Using this widget, it is very easy to give your app a look and feel that conforms to the guidelines mentioned in Google's material design specification. Support Older Versions At the time of writing, near about 71% of Android devices run Android Lollipop. However, thanks to the v7 Support Library, you can use the RecyclerView and CardView widgets on devices that run older versions of Android by adding the following lines to the dependencies section in your project's build.grade file: compile 'com.android.support:cardview-v7:26.0.0-alpha1' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' Creating a CardView A CardView is a ViewGroup. Like any other ViewGroup, it can be added to your Activity or Fragment using a layout XML file. To create an empty CardView, you would have to a...

How to make tabs in Android

One of the best things about technology is that it keeps on changing. On the same lines recently some significant improvements were made for Android by the means of support library. The new Design Support Library was included in the support repository. This new Android Design Support library features many new UI components like snackbars, floating action buttons and of-course it significantly improves the implementation of Android Tabs. Since Android design support library contains many new UI widgets which were introduced as concepts with material design. I would write separate tutorials for each one of those. Here lets concentrate on the Android tabs example. Earlier to make tabs in Android, action bar was used. But now with API 21 onwards it has been deprecated. An alternative way to make tabs with full backward support was to use SlidingTabLayout and SlidingTabStrip classes. But now with Android Design Support Library making swipe tabs has become even more simpler. In this Andro...

What is Context in Android

W hile developing Android applications, we all see and use the term context. But for most new programmers its a nightmare to resolve a context related error. This post helps you understand what context really means in Android Context in Android is an interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc. Every boss has an assistant to look after, to do all less important and time consuming tasks. If a file or a cup of coffee is needed, assistant is on the run. Some bosses barely know what’s going on in the office, so they ask their assistants regarding this too. They do some work themselves but for most other things they need help of their assistants. In this scenario, Boss –  is the  Androi...

What is ViewPager in Android

ViewPager in Android allows the user to flip left and right through pages of data. In our android ViewPager application we’ll implement a ViewPager that swipes through three views with different images and texts. Android ViewPager widget is found in the support library and it allows the user to swipe left or right to see an entirely new screen. ViewPager s have built-in swipe gestures to transition through pages, and they display screen slide animations by default, so you don't need to create any.  ViewPager s use  PagerAdapter s as a supply for new pages to display, so the  PagerAdapter  will use the fragment class that you created earlier.

How to add dependencies in Android Studio

1. Go to Build Tab in Android Studio 2. Go to Edit Libraries and Dependencies 3. Go to Dependencies and click plus button 4. Choose the desired library and click ok