android learning tutorial
DESCRIPTION
Android Learning TutorialTRANSCRIPT
3/16/2014 Android Learning Tutorial
http://sunil-android.blogspot.in/search?updated-max=2013-07-24T13:18:00-07:00&max-results=7&start=14&by-date=false 9/19
Posted by sunil gupta at 03:43 5 comments:
Labels: ListFragment
Location: Bangalore, Karnataka, India
+1 Recommend this on Google
Saturday, 13 July 2013
What is Fragment ? And Start With HelloFragment
Hi guys!!
Today I am going to discuss about Fragment. Now it is available with new API open source library android-
support v4 or v7 or v13. android-support v13 is the recent api library.
So lets start to know about fragment the question is arises first what is 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 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.
A fragment has its own life-cycle, closely related to the life-cycle 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 have a few extra life cycle callbacks managing interaction with the activity:
onAttach(Activity) => Called when the fragment has been associated with the activity.
onCreateView(LayoutInflater, ViewGroup, Bundle) => Called to create the view hierarchy
associated
What is Fragment in Android?
What is Life cycle of Fragment ?
3/16/2014 Android Learning Tutorial
http://sunil-android.blogspot.in/search?updated-max=2013-07-24T13:18:00-07:00&max-results=7&start=14&by-date=false 10/19
with the fragment.
onActivityCreated(Bundle) => Called when the activity’s onCreate() method has returned.
onDestroyView() => Called when the view hierarchy associated with the fragment is being
removed.
onDetach() => Called when the fragment is being disassociated from the activity.
Fragments were added to the Android API in Honeycomb, API 11.
The primary classes related to fragments are:
android.app.Fragment
android.app.FragmentManager
android.app.FragmentTransaction
The primary classes related to fragments are available in library package are:
android.support.v4.app.FragmentActivity
android.support.v4.app.Fragment
android.support.v4.app.FragmentManager
android.support.v4.app.FragmentTransaction
To use the Compatibility Package features, your activity must use android.support.v4.app.
FragmentActivity as a base class, rather than android.app.Activity or one of its subclasses.
Lets start the use of this fragment with Simple Hello Fragment.
Fragment Implemented ?
main.xml
1234
<linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" <fragment android:layout_height="wrap_content" android:layout_width="fill_parent" android:name=</fragment></linearlayout>
hello_fragment.xml
12
<linearlayout android:layout_height="match_parent" android:layout_width="match_parent"
?
?
3/16/2014 Android Learning Tutorial
http://sunil-android.blogspot.in/search?updated-max=2013-07-24T13:18:00-07:00&max-results=7&start=14&by-date=false 11/19
Posted by sunil gupta at 00:37 1 comment:
Labels: What is Fragment
Location: Bangalore, Karnataka, India
Cheers Guys!!
Please share this site guys!
KidsMitra
34
<textview android:layout_gravity="center_horizontal" android:layout_height="wrap_content"</textview></linearlayout>
HelloFragment
123456789101112131415161718
package com.sunil.fragment; import com.sunil.fragment.R;import android.os.Bundle;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup; public class HelloFragment extends Fragment{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.hello_fragment_layout, null); return v; } }
MainActivity.java
1234567891011121314
package com.sunil.fragment; import com.sunil.fragment.R;import android.os.Bundle;import android.support.v4.app.FragmentActivity; public class MainActivity extends FragmentActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }}
+1 Recommend this on Google
Tuesday, 2 July 2013
Mostly Used Android Code
Hi Guys!
?
?