Monday 31 March 2014

Migrating from Web to Android

Hello there! If you're here, I assume you're a web developer who is getting to learn Android, much like me. When I dipped into Android, the very first thing that confused me was 'how navigation works in Android apps, like we've several pages in a website which we can create an edit, where to do all such stuff in Android?' and 'what is this all heck of activity and XML files?'. While I had a little (yes, little and theoretical only) experience of Java, I knew about concepts of OOP (Polymorphism, Abstraction, Encapsulation and Inheritance). If you don't know about them, you better check out some links on these topics before returning to this page.
So, the first thing to understand in Android is that, 'Activities' are what we typically call 'pages' in Websites and the much likeinteraction that we did with the UI items in websites (such as with 'buttons ' in a webpage), we do so here with the help of Intents. Intents specify an "app's intent to do something with the app". This can, besides, be used to perform a number of tasks, however, we primarily use it perform interaction between activities. We'll discuss them all later.
So, as many pages your want to have in your app, you'll have to create that many activities. In fact, activities are more closely similar to 'views' and that's exactly what we call in Android.
The following post and the upcoming ones will contain important points, using the standard android documentation from it's site. I hope that i do not sound  confusing and that it helps you out in understanding Android.

1. Building a Simple UI
  •  The graphical user interface (GUI) of an app is create using a hierarchy of View and ViewGroup objects. It forms a tree structure where each leaf node can contain either a View object or a ViewGroup object. In simple language, any page can contain a view (page layout) as well as ViewGroup object. And actually, that's how we link Views in Android apps. A basic diagram (above) shows the concept. The LinearLayout and RelativeLayout are the ViewGroup object types which define the type of view layout selected.
  •  View objects are usually UI widgets such as buttons, text-fields, like we have them in a typical web page. However, their attribute declaration is different here. Generally, we define everything in an XML file (which we'll discuss later).
  •  ViewGroup objects are 'invisible' (yes, they're mere a definition) containers that define how the child views are laid out, such as in a grid or a vertical list.
  • UI layout is defined in XML using hierarchy of UI elements.
 Next, we'll discuss how to create a Linear layout in Android. Follow up!

No comments:

Post a Comment