Step 1: build.gradle compile 'com.android.support:cardview-v7:26+' compile 'com.android.support:recyclerview-v7:26.+' Step 2: main_activity.xml <? 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= "csdevbin.arham.recyclerviewdemo.MainActivity" > < android.support.v7.widget.RecyclerView android :id= "@+id/my_recycler_view" android :layout_width= "match_parent" android :layout_height= "match_parent" android :scrollbars= "vertical" /> </ Relati
Posts
Here is the list of methods which you can to override in your fragment class − onAttach() The fragment instance is associated with an activity instance.The fragment and the activity is not fully initialized. Typically you get in this method a reference to the activity which uses the fragment for further initialization work. onCreate() The system calls this method when creating the fragment. You should initialize essential components of the fragment that you want to retain when the fragment is paused or stopped, then resumed. onCreateView() The system calls this callback when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View component from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI. onActivityCreated() The onActivityCreated() is called after the onCreateView() method when the host activity is created. Activ
Let's see the 7 lifecycle methods of android activity. Method Description onCreate called when activity is first created. onStart called when activity is becoming visible to the user. onResume called when activity will start interacting with the user. onPause called when activity is not visible to the user. onStop called when activity is no longer visible to the user. onRestart called after your activity is stopped, prior to start. onDestroy called before the activity is destroyed. package csdevbin.lifecycle; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.