.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

What is Fragment ? And Start With HelloFragment

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh

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?

What is Fragment in Android?

  • 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.

What is Life cycle of Fragment ?

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   
 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.


  Fragment Implemented ?

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. 

main.xml





hello_fragment.xml





HelloFragment

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

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);
}
}

Cheers Guys!!

Please share this site guys!
KidsMitra

Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel What is Fragment ? And Start With HelloFragment , Diterbitkan oleh scodeaplikasi pada Sabtu, 13 Juli 2013. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to