Android java code with Fragment example

Following different Android Java code shows how to use Fragment in Android Java

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".PreferencesFragment"> <!-- TODO: Update blank fragment layout --> <TextView android:layout_width="match_parent" android:layout_height="300dp" android:text="@string/hello_blank_fragment" /> <!-- TODO: Update blank fragment layout --> <TextView android:layout_width="match_parent" android:layout_height="300dp" android:text="@string/hello_blank_fragment" /> </FrameLayout>

package com.indiacitys.cityclassifieds; import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * Created by Murali on 8/26/2015. */ public class PreferencesFragment extends Fragment { public PreferencesFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_preferences, container, false); } }
Sign In or Register to comment.