<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":106,"date":"2021-07-11T05:28:24","date_gmt":"2021-07-11T05:28:24","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=106"},"modified":"2021-09-15T06:12:40","modified_gmt":"2021-09-15T06:12:40","slug":"android-fragments","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/","title":{"rendered":"Android Fragments"},"content":{"rendered":"<div class=\"ImageContent\">\n<div class=\"hddn\" style=\"text-align: justify;\"><img decoding=\"async\" class=\"img-responsive center-block\" src=\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png\" alt=\" Android Fragments \" \/><\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"what-is-fragments\" class=\"color-pink\">What is Fragments?<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>A Fragment is a piece of an activity which enable more modular activity design. It will not be wrong if we say, a fragment is a kind of sub-activity. A fragment has its own\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/android\/layouts-in-android\" target=\"_blank\" rel=\"noopener\">layout<\/a>\u00a0and its own behavior with its own life cycle\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/android\/android-call\" target=\"_blank\" rel=\"noopener\">callbacks.<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>You can add or remove fragments in an\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/android\/android-start-activity\" target=\"_blank\" rel=\"noopener\">activity<\/a>\u00a0while the activity is running.<\/li>\n<li>You can combine multiple fragments in a single activity to build a multi-plane UI.<\/li>\n<li>Android Fragment is the part of activity, it is also known as sub-activity. There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity.<\/li>\n<li>Android fragment lifecycle is affected by activity lifecycle because fragments are included in activity.<\/li>\n<li>Each fragment has its own life cycle methods that is affected by\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/android\/android-activity-lifecycle\" target=\"_blank\" rel=\"noopener\">activity life cycle<\/a>\u00a0because fragments are embedded in activity.<\/li>\n<li>The Fragment Manager class is responsible to make interaction between fragment objects.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"android-fragment-lifecycle\" class=\"color-purple\">Android Fragment Lifecycle<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>The lifecycle of android fragment is like the activity lifecycle. There are 12 lifecycle methods for fragment.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<table class=\"table-bordered table-striped table table-responsive\">\n<tbody>\n<tr>\n<th class=\"text-center\">No.<\/th>\n<th class=\"text-center\">Method<\/th>\n<th class=\"text-center\">Description<\/th>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">1.<\/td>\n<td class=\"text-leftalign\">onAttach(Activity)<\/td>\n<td class=\"text-leftalign\">it is called only once when it is attached with activity.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">2.<\/td>\n<td class=\"text-leftalign\">onCreate(Bundle)<\/td>\n<td class=\"text-leftalign\">It is used to initialize the fragment.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">3.<\/td>\n<td class=\"text-leftalign\">onCreateView(LayoutInflater, ViewGroup, Bundle)<\/td>\n<td class=\"text-leftalign\">creates and returns view hierarchy.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">4.<\/td>\n<td class=\"text-leftalign\">onActivityCreated(Bundle)<\/td>\n<td class=\"text-leftalign\">It is invoked after the completion of onCreate() method.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">5.<\/td>\n<td class=\"text-leftalign\">onViewStateRestored(Bundle)<\/td>\n<td class=\"text-leftalign\">It provides information to the fragment that all the saved state of fragment view hierarchy has been restored.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">6.<\/td>\n<td class=\"text-leftalign\">onStart()<\/td>\n<td class=\"text-leftalign\">makes the fragment visible.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">7.<\/td>\n<td class=\"text-leftalign\">onResume()<\/td>\n<td class=\"text-leftalign\">makes the fragment interactive.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">8.<\/td>\n<td class=\"text-leftalign\">onPause()<\/td>\n<td class=\"text-leftalign\">is called when fragment is no longer interactive.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">9.<\/td>\n<td class=\"text-leftalign\">onStop()<\/td>\n<td class=\"text-leftalign\">is called when fragment is no longer visible.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">10.<\/td>\n<td class=\"text-leftalign\">onDestroyView()<\/td>\n<td class=\"text-leftalign\">allows the fragment to clean up resources.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">11.<\/td>\n<td class=\"text-leftalign\">onDestroy()<\/td>\n<td class=\"text-leftalign\">allows the fragment to do final clean up of fragment state.<\/td>\n<\/tr>\n<tr>\n<td class=\"text-leftalign\">12.<\/td>\n<td class=\"text-leftalign\">onDetach()<\/td>\n<td class=\"text-leftalign\">It is called immediately prior to the fragment no longer being associated with its activity.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"ImageContent\" style=\"text-align: justify;\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block\" src=\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/android-fragment-life-cycle.png\" alt=\"android fragment life cycle\" \/><\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"using-a-fragment\" class=\"color-purple\">Using a fragment<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>The general steps to use a Fragment:<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Create a subclass of Fragment.<\/li>\n<li>Create a layout for the Fragment.<\/li>\n<li>Add the Fragment to a host Activity, either statically or dynamically.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"creating-a-fragment\" class=\"color-purple\">Creating a fragment<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>To create a Fragment in an app, extend the Fragment class, then override key lifecycle methods to insert your app logic, similar to the way of Activity class.<\/li>\n<li>Instead of extending the base Fragment class, you can extend one of these other, more specific Fragment subclasses:\n<ul>\n<li><b>DialogFragment :<\/b>\u00a0Displays a floating dialog, such as a date picker or time picker.<\/li>\n<li><b>ListFragment :<\/b>\u00a0Displays a list of items that are managed by an adapter (such as a SimpleCursorAdapter).<\/li>\n<li><b>PreferenceFragment :<\/b>\u00a0Displays a hierarchy of Preference objects as a list, similar to PreferenceActivity. This is useful when creating a &#8220;settings&#8221; Activity for your app.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"how-to-create-a-fragment-in-android-studio\">How to create a Fragment in Android Studio<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>In Project: Android view, expand app &gt; java and select the folder containing the Java code for your app.<\/li>\n<li>Choose File &gt; New &gt; Fragment &gt; Fragment (Blank).<\/li>\n<li>Name the Fragment something like SimpleFragment, or use the supplied name (BlankFragment).<\/li>\n<li>If your Fragment has a UI, check the Create layout XML option if it is not already checked. Other options include:<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li><b>Include fragment factory methods :<\/b>\u00a0Include sample factory method code to initialize the Fragment arguments in a way that encapsulates and abstracts them. Select this option if the number of arguments would make a constructor too complex.<\/li>\n<li><b>Include interface callbacks :<\/b>\u00a0Select this option if you want to include sample code that defines an interface in the Fragment with callback methods that enable the Fragment to communicate with its host Activity.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Click Finish to create a Fragment.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"android-fragment-classes\" class=\"color-purple\">Android Fragment Classes<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Fragments were added to the Android API in Honeycomb(API 11).\n<ul>\n<li>android.app.Fragment : The base class for all fragment definitions<\/li>\n<li>android.app.FragmentManager : The class for interacting with fragment objects inside an activity<\/li>\n<li>android.app.FragmentTransaction : The class for performing an atomic set of fragment operations<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>When using a compatibility package library provided by Google, the following classes are used for implementation.\n<ul>\n<li>android.support.v4.app.FragmentActivity : The base class for all activities using compatibility-based fragment (and loader) features<\/li>\n<li>android.support.v4.app.Fragment<\/li>\n<li>android.support.v4.app.FragmentManager<\/li>\n<li>android.support.v4.app.FragmentTransaction<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"android-fragment-example\" class=\"color-blue\">Android Fragment Example<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>Let&#8217;s have a look at the simple example of android fragment.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"activity_main-xml\">activity_main.xml<\/h2>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\"><div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;  <br\/>    android:layout_width=&quot;fill_parent&quot;  <br\/>    android:layout_height=&quot;fill_parent&quot; &gt;  <br\/>  <br\/>    &lt;fragment  <br\/>        android:id=&quot;@+id\/fragment2&quot;  <br\/>        android:name=&quot;com.example.fragmentexample.Fragment2&quot;  <br\/>        android:layout_width=&quot;0px&quot;  <br\/>        android:layout_height=&quot;match_parent&quot;   <br\/>        android:layout_weight=&quot;1&quot;  <br\/>        \/&gt;  <br\/>  <br\/>    &lt;fragment  <br\/>        android:id=&quot;@+id\/fragment1&quot;  <br\/>        android:name=&quot;com.example.fragmentexample.Fragment1&quot;  <br\/>        android:layout_width=&quot;0px&quot;  <br\/>        android:layout_height=&quot;match_parent&quot;  <br\/>        android:layout_weight=&quot;1&quot;  <br\/>         \/&gt;  <br\/>  <br\/>&lt;\/LinearLayout&gt;  <\/code><\/pre> <\/div><\/figure>\n<\/div>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"file-fragment1-xml\">File: fragment1.xml<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;  <br\/>&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;  <br\/>    android:layout_width=&quot;match_parent&quot;  <br\/>    android:layout_height=&quot;match_parent&quot;  <br\/>    android:orientation=&quot;vertical&quot;  <br\/>    android:background=&quot;#00ff00&quot;  <br\/>     &gt;  <br\/>  <br\/>    &lt;TextView  <br\/>        android:id=&quot;@+id\/textView1&quot;  <br\/>        android:layout_width=&quot;wrap_content&quot;  <br\/>        android:layout_height=&quot;wrap_content&quot;  <br\/>        android:text=&quot;fragment frist&quot;  <br\/>        android:textAppearance=&quot;?android:attr\/textAppearanceLarge&quot; \/&gt;  <br\/>  <br\/>&lt;\/LinearLayout&gt;<\/code><\/pre> <\/div>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"file-fragment2-xml\">File: fragment2.xml<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;  <br\/>&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;  <br\/>    android:layout_width=&quot;match_parent&quot;  <br\/>    android:layout_height=&quot;match_parent&quot;  <br\/>    android:orientation=&quot;vertical&quot;  <br\/>    android:background=&quot;#0000ff&quot;  <br\/>     &gt;  <br\/>  <br\/>    &lt;TextView  <br\/>        android:id=&quot;@+id\/textView1&quot;  <br\/>        android:layout_width=&quot;wrap_content&quot;  <br\/>        android:layout_height=&quot;wrap_content&quot;  <br\/>        android:text=&quot;Second Fragment&quot;  <br\/>        android:textAppearance=&quot;?android:attr\/textAppearanceLarge&quot; \/&gt;  <br\/>  <br\/>&lt;\/LinearLayout&gt;<\/code><\/pre> <\/div>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"mainactivity-class\">MainActivity class<\/h2>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"file-mainactivity-java\">File: MainActivity.java<\/h2>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\"><div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">package com.example.fragmentexample;  <br\/>  <br\/>import android.os.Bundle;  <br\/>import android.app.Activity;  <br\/>import android.view.Menu;  <br\/>public class MainActivity extends Activity {  <br\/>  <br\/>    @Override  <br\/>    protected void onCreate(Bundle savedInstanceState) {  <br\/>        super.onCreate(savedInstanceState);  <br\/>        setContentView(R.layout.activity_main);  <br\/>    }  <br\/>}<\/code><\/pre> <\/div><\/figure>\n<\/div>\n<\/div>\n<div class=\"subheading\" style=\"text-align: justify;\">\n<h2 id=\"file-fragment1-java\">File: Fragment1.java<\/h2>\n<\/div>\n<div class=\"CodeContent\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\"><div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">ackage com.example.fragmentexample;  <br\/>  <br\/>import android.app.Fragment;  <br\/>import android.os.Bundle;  <br\/>import android.view.LayoutInflater;  <br\/>import android.view.View;  <br\/>import android.view.ViewGroup;  <br\/>  <br\/>public class Fragment1 extends Fragment {  <br\/>    @Override  <br\/>    public View onCreateView(LayoutInflater inflater, ViewGroup container,  <br\/>            Bundle savedInstanceState) {  <br\/>        \/\/ TODO Auto-generated method stub  <br\/>        return inflater.inflate(R.layout.fragment1,container, false);  <br\/>    }  <br\/>  <br\/>} <\/code><\/pre> <\/div><\/figure>\n<\/div>\n<\/div>\n<div class=\"ImageContent\" style=\"text-align: justify;\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/android-activity-cycle.png\" alt=\"android activity and fragment life cycle\" \/><\/div>\n<\/div>\n<div class=\"subheading\">\n<h2 id=\"file-fragment2-java\" style=\"text-align: justify;\">File: Fragment2.java<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">package com.example.fragmentexample;  <br\/>  <br\/>import android.app.Fragment;  <br\/>import android.os.Bundle;  <br\/>import android.view.LayoutInflater;  <br\/>import android.view.View;  <br\/>import android.view.ViewGroup;  <br\/>  <br\/>public class Fragment2 extends Fragment {  <br\/>      <br\/>    public View onCreateView(LayoutInflater inflater, ViewGroup container,  <br\/>            Bundle savedInstanceState) {  <br\/>        \/\/ TODO Auto-generated method stub  <br\/>        return inflater.inflate(R.layout.fragment2,container, false);  <br\/>    }  <br\/>  <br\/>} <\/code><\/pre> <\/div>\n<div class=\"TextHeading\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<h2 id=\"output\" class=\"color-green\">Output<\/h2>\n<\/div>\n<\/div>\n<div class=\"ImageContent\">\n<div class=\"hddn\"><img decoding=\"async\" class=\"img-responsive center-block aligncenter\" src=\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/android-fragment.png\" alt=\" Android Fragments \" \/><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : A Fragment is a piece of an activity which enable more modular&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[105],"tags":[195,161,175,219,201,146,140,145,132,144,133,143,151,156,155,137,182,190,177,193,187,160,172,178,148,135,153,142,185,150,159,152,180,136,157,141,179,221,211,203,199,214,198,209,205,147,149,220,194,222,184,171,173,188,164,186,189,174,218,154,176,196,212,213,223,215,207,204,217,202,208,206,210,200,197,192,158,191,216],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-android","tag-accenture-interview-questions-and-answers","tag-activity-lifecycle-in-android","tag-add-fragment-to-activity","tag-agreeya-solutions-interview-questions-and-answers","tag-allstate-solutions-pvt-ltd-interview-questions-and-answers","tag-android-api","tag-android-app-development","tag-android-app-store","tag-android-apps","tag-android-apps-download","tag-android-developer","tag-android-development","tag-android-development-tutorial","tag-android-device","tag-android-download","tag-android-emulator","tag-android-fragment","tag-android-fragment-example","tag-android-fragment-example-source-code","tag-android-fragment-lifecycle","tag-android-fragment-tutorial","tag-android-lifecycle","tag-android-multiple-fragments-in-one-activity-example","tag-android-phones","tag-android-programming","tag-android-sdk","tag-android-service","tag-android-software","tag-android-studio-fragment","tag-android-studio-tutorial","tag-android-system","tag-android-tutorial","tag-android-update","tag-android-versions","tag-android-video","tag-apps-for-android","tag-best-android-phone","tag-bharti-airtel-interview-questions-and-answers","tag-bosch-india-software-interview-questions-and-answers","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-chetu-interview-questions-and-answers","tag-collabera-technologies-interview-questions-and-answers","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-developer-android","tag-eclipse-android","tag-electronics-arts-inc-interview-questions-and-answers","tag-examples-of-fragments","tag-flipkart-interview-questions-and-answers","tag-fragment-android","tag-fragment-android-example","tag-fragment-example-in-android-studio","tag-fragment-examples","tag-fragment-lifecycle","tag-fragmentmanager","tag-fragments-in-android","tag-fragments-in-android-example-androidhive","tag-g-cube-webwide-software-pvt-ltd-interview-questions-and-answers","tag-google-android","tag-how-to-call-fragment-from-activity-in-android-example","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-infosys-technologies-interview-questions-and-answers","tag-lava-international-ltd-interview-questions-and-answers","tag-maintec-technologies-pvt-ltd-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-photon-interactive-pvt-ltd-interview-questions-and-answers","tag-prokarma-softech-pvt-ltd-interview-questions-and-answers","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-symphony-teleca-interview-questions-and-answers","tag-tech-mahindra-interview-questions-and-answers","tag-unitedhealth-group-interview-questions-and-answers","tag-what-is-a-fragment","tag-what-is-android","tag-what-is-fragment","tag-wipro-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Fragments - Android Interview Questions and Answers<\/title>\n<meta name=\"description\" content=\"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Fragments - Android Interview Questions and Answers\" \/>\n<meta property=\"og:description\" content=\"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-11T05:28:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-15T06:12:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/\",\"name\":\"Android Fragments - Android Interview Questions and Answers\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png\",\"datePublished\":\"2021-07-11T05:28:24+00:00\",\"dateModified\":\"2021-09-15T06:12:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage\",\"url\":\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png\",\"contentUrl\":\"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Fragments - Android Interview Questions and Answers","description":"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/","og_locale":"en_US","og_type":"article","og_title":"Android Fragments - Android Interview Questions and Answers","og_description":"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/","og_site_name":"Wikitechy","article_published_time":"2021-07-11T05:28:24+00:00","article_modified_time":"2021-09-15T06:12:40+00:00","og_image":[{"url":"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png"}],"author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/","name":"Android Fragments - Android Interview Questions and Answers","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png","datePublished":"2021-07-11T05:28:24+00:00","dateModified":"2021-09-15T06:12:40+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"Android Fragments - Android Interview Questions and Answers - A Fragment is a piece of an activity which enable more modular activity design.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/android\/android-fragments\/#primaryimage","url":"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png","contentUrl":"https:\/\/cdn.wikitechy.com\/tutorials\/android\/fragment-android.png"},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":5,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":3810,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/106\/revisions\/3810"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}