Posts

Creating Navigation tabs Example

Image
NavigationTabExample   MainActivity.java package com.madhu; import android.os.Bundle; import android.os.StrictMode; import android.support.v4.app.FragmentActivity; import android.widget.TabHost; public class MainActivity extends FragmentActivity { TabHost tHost;     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);               tHost = (TabHost) findViewById(android.R.id.tabhost);         tHost.setup();               /** Defining Tab Change Listener event. This is invoked when tab is changed */         TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.Fragmen...

Android Application Life cycle

Image
By default, each Android application is run in its own process that’s running a separate instance of Dalvik. Memory and process management of each application is handled exclusively  by the run time. While uncommon, it’s possible to force application components within the same application to run in different processes or to have multiple applications share the same process using the android:process attribute on the affected component nodes within the manifest. Android aggressively manages its resources, doing whatever it takes to ensure that the device remains  responsive. This means that processes (and their hosted applications) will be killed, without warning if  necessary, to free resources for higher-priority applications — generally those that are interacting  directly with the user at the time. The prioritization process is discussed in the next section. Understanding Application Priority and Process States The order in which processes ...

Fragment

Image
 What’s a Fragment? A  fragment  is a class implementing a portion of an activity. A fragment represents a particular operation or interface running within a larger activity. Fragments enable more modular activity design, making it easier to adapt an application to different screen orientations and multiple screen sizes. Fragments must be embedded in activities; they cannot run independent of activities. Most fragments define their own layout of views that live within the activity’s view hierarchy. However, a fragment can implement a behavior that has no user interface component. A fragment has its own lifecycle, closely related to the lifecycle of its host activity. A fragment can be a static part of an activity, instantiated automatically during the activity’s creation. Or, you can create, add, and remove fragments dynamically in an activity at run-time. Fragments: Implemented in Honeycomb (3.0) or Later Fragments were ad...