Created
April 9, 2018 14:52
-
-
Save chiamakaikeanyi/9a8fb6ebd987c7bcd4043ba653a5a97b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //fragment | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:id="@+id/my_placeholder" | |
| android:layout_width="match_parent" | |
| android:layout_height="@dimen/question_height" | |
| android:layout_marginEnd="@dimen/question_margin" | |
| android:layout_marginLeft="@dimen/question_margin" | |
| android:layout_marginRight="@dimen/question_margin" | |
| android:layout_marginStart="@dimen/question_margin" | |
| android:gravity="center_vertical" | |
| android:textAlignment="center" | |
| android:textSize="@dimen/category_text_size" /> | |
| //fragment class | |
| //check the onCreateView method | |
| package com.chiamakaikeanyi.android.orbital; | |
| import android.content.Context; | |
| import android.net.Uri; | |
| import android.os.Bundle; | |
| import android.support.v4.app.Fragment; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.widget.TextView; | |
| /** | |
| * A simple {@link Fragment} subclass. | |
| * Activities that contain this fragment must implement the | |
| * {@link OrbitFragment.OnFragmentInteractionListener} interface | |
| * to handle interaction events. | |
| * Use the {@link OrbitFragment#newInstance} factory method to | |
| * create an instance of this fragment. | |
| */ | |
| public class OrbitFragment extends Fragment { | |
| // TODO: Rename parameter arguments, choose names that match | |
| // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | |
| private static final String ARG_PARAM1 = "param1"; | |
| private static final String ARG_PARAM2 = "param2"; | |
| // TODO: Rename and change types of parameters | |
| private String mParam1; | |
| private String mParam2; | |
| private OnFragmentInteractionListener mListener; | |
| public OrbitFragment() { | |
| // Required empty public constructor | |
| } | |
| /** | |
| * Use this factory method to create a new instance of | |
| * this fragment using the provided parameters. | |
| * | |
| * @param param1 Parameter 1. | |
| * @param param2 Parameter 2. | |
| * @return A new instance of fragment OrbitFragment. | |
| */ | |
| // TODO: Rename and change types and number of parameters | |
| public static OrbitFragment newInstance(String param1, String param2) { | |
| OrbitFragment fragment = new OrbitFragment(); | |
| Bundle args = new Bundle(); | |
| args.putString(ARG_PARAM1, param1); | |
| args.putString(ARG_PARAM2, param2); | |
| fragment.setArguments(args); | |
| return fragment; | |
| } | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| if (getArguments() != null) { | |
| mParam1 = getArguments().getString(ARG_PARAM1); | |
| mParam2 = getArguments().getString(ARG_PARAM2); | |
| } | |
| } | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
| Bundle savedInstanceState) { | |
| // Inflate the layout for this fragment | |
| View rootView = inflater.inflate(R.layout.fragment_orbit, container, false); | |
| TextView textView = (TextView) rootView.findViewById(R.id.my_placeholder); | |
| textView.setText("@string/androidquestion1"); | |
| return rootView; | |
| } | |
| // TODO: Rename method, update argument and hook method into UI event | |
| public void onButtonPressed(Uri uri) { | |
| if (mListener != null) { | |
| mListener.onFragmentInteraction(uri); | |
| } | |
| } | |
| @Override | |
| public void onAttach(Context context) { | |
| super.onAttach(context); | |
| if (context instanceof OnFragmentInteractionListener) { | |
| mListener = (OnFragmentInteractionListener) context; | |
| } else { | |
| throw new RuntimeException(context.toString() | |
| + " must implement OnFragmentInteractionListener"); | |
| } | |
| } | |
| @Override | |
| public void onDetach() { | |
| super.onDetach(); | |
| mListener = null; | |
| } | |
| /** | |
| * This interface must be implemented by activities that contain this | |
| * fragment to allow an interaction in this fragment to be communicated | |
| * to the activity and potentially other fragments contained in that | |
| * activity. | |
| * <p> | |
| * See the Android Training lesson <a href= | |
| * "http://developer.android.com/training/basics/fragments/communicating.html" | |
| * >Communicating with Other Fragments</a> for more information. | |
| */ | |
| public interface OnFragmentInteractionListener { | |
| // TODO: Update argument type and name | |
| void onFragmentInteraction(Uri uri); | |
| } | |
| } | |
| //Fragment Activity | |
| package com.chiamakaikeanyi.android.orbital; | |
| import android.os.Bundle; | |
| import android.support.v4.app.FragmentManager; | |
| import android.support.v7.app.AppCompatActivity; | |
| public class OrbitActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_orbit); | |
| // Begin the transaction | |
| FragmentManager fragmentManager = getSupportFragmentManager(); | |
| // Replace the contents of the container with the new fragment | |
| fragmentManager.beginTransaction() | |
| .add(R.id.question_container, new OrbitFragment()) | |
| .commit(); | |
| } | |
| } | |
| //Housing Activity | |
| //Check the FrameLayout | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context="com.chiamakaikeanyi.android.orbital.AndroidActivity"> | |
| <LinearLayout | |
| android:id="@+id/content" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_below="@id/timer" | |
| android:orientation="vertical" | |
| android:padding="@dimen/activity_vertical_margin"> | |
| <FrameLayout | |
| android:id="@+id/question_container" | |
| android:layout_width="match_parent" | |
| android:layout_height="@dimen/question_height" | |
| android:scaleType="centerInside"/> | |
| <android.support.v7.widget.CardView | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content"> | |
| <RadioGroup | |
| android:id="@+id/android_question_one" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:orientation="vertical" | |
| android:paddingBottom="@dimen/five_dp"> | |
| <RadioButton | |
| android:id="@+id/android_virtual_display" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@drawable/semi_rounded_corners" | |
| android:padding="@dimen/activity_vertical_margin" | |
| android:text="@string/android11" | |
| android:textColor="@color/colorGrey" /> | |
| <View | |
| android:layout_width="match_parent" | |
| android:layout_height="@dimen/one_dp" | |
| android:background="@android:color/darker_gray" /> | |
| <RadioButton | |
| android:id="@+id/android_virtual_device" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@drawable/semi_rounded_corners" | |
| android:padding="@dimen/activity_vertical_margin" | |
| android:text="@string/android12" | |
| android:textColor="@color/colorGrey" /> | |
| <View | |
| android:layout_width="match_parent" | |
| android:layout_height="@dimen/one_dp" | |
| android:background="@android:color/darker_gray" /> | |
| <RadioButton | |
| android:id="@+id/active_virtual_device" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@drawable/semi_rounded_corners" | |
| android:padding="@dimen/activity_vertical_margin" | |
| android:text="@string/android13" | |
| android:textColor="@color/colorGrey" /> | |
| <View | |
| android:layout_width="match_parent" | |
| android:layout_height="@dimen/one_dp" | |
| android:background="@android:color/darker_gray" /> | |
| <RadioButton | |
| android:id="@+id/application_virtual_display" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:background="@drawable/semi_rounded_corners" | |
| android:padding="@dimen/activity_vertical_margin" | |
| android:text="@string/android14" | |
| android:textColor="@color/colorGrey" /> | |
| </RadioGroup> | |
| </android.support.v7.widget.CardView> | |
| <LinearLayout | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_gravity="center" | |
| android:layout_margin="@dimen/activity_vertical_margin" | |
| android:orientation="horizontal"> | |
| <ProgressBar | |
| android:id="@+id/progress_bar" | |
| style="@style/Widget.AppCompat.ProgressBar.Horizontal" | |
| android:layout_width="0dp" | |
| android:layout_height="wrap_content" | |
| android:layout_marginEnd="@dimen/ten_dp" | |
| android:layout_marginRight="@dimen/ten_dp" | |
| android:layout_marginTop="@dimen/two_dp" | |
| android:layout_weight="3" | |
| android:indeterminate="false" | |
| android:max="100" | |
| android:progress="10" /> | |
| <TextView | |
| android:id="@+id/current_page" | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="@string/one" | |
| android:textAlignment="center" | |
| android:textColor="@color/colorPrimary" | |
| android:textSize="@dimen/location_text_size" /> | |
| <TextView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="@string/divider" | |
| android:textAlignment="center" | |
| android:textColor="@color/colorPrimary" | |
| android:textSize="@dimen/location_text_size" /> | |
| <TextView | |
| android:layout_width="wrap_content" | |
| android:layout_height="wrap_content" | |
| android:text="@string/ten" | |
| android:textAlignment="center" | |
| android:textColor="@color/colorPrimary" | |
| android:textSize="@dimen/location_text_size" /> | |
| </LinearLayout> | |
| </LinearLayout> | |
| <TextView | |
| android:id="@+id/next" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_alignParentBottom="true" | |
| android:layout_below="@id/content" | |
| android:background="@color/colorLightGrey" | |
| android:padding="@dimen/fifteen_dp" | |
| android:text="@string/next" | |
| android:textAlignment="center" | |
| android:textColor="@color/colorGrey" | |
| android:textSize="@dimen/sixteen_sp" | |
| android:textStyle="bold" | |
| android:visibility="visible" /> | |
| </RelativeLayout> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment