Posts

Showing posts from July, 2020

Create Tablayout without Viewpager in Android. Tabs in Android with Fragments

Crate Tablayout with Viewpager and fragments : https://code8808.blogspot.com/2020/07/create-tablayout-in-android-tabs-in.html In this we dont use a Viewpager , due to which we do not get the SLIDING EFFECT. We use a lsitener on the Tablayout and get the Position of the selected tab using the getPosition() method on tab data passed to the onTabSelected() method. Then we use fragmentsupportmanager to replace the fragments in the FRAMELAYOUT container. Activity_main.xml :  <? xml version ="1.0" encoding ="utf-8" ?> <LinearLayout 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" android :orientation ="vertical" xmlns: app ="http://schemas.android.com/apk/res-auto" tools :context =".MainActivity" > <com.google.android.materia...

Check Internet connection in Android Java

step 1] Mention the 2 permissions in the Android Manifest file  <uses-permission android :name ="android.permission.INTERNET" /> <uses-permission android :name ="android.permission.ACCESS_NETWORK_STATE" /> The Internet permission to use the Internet  The ACESS_NETWORK_STATE permisison to check the state of  the network. Acess_Network_state gives acess to all the networks on the device , which are connected and which are not connected. Step2] create the object of Connectivitymanager and get its system service. Step 3] Create a object of NetworkInfo class and apply its getActiveNetworkInfo() method using the Connectivitymanager object The getActiveNetworkInfo() contains all the Connection details. if no connection are available then it is empty. Apply the isconnected() method to check if the device is connected to a network. if Yes it returns True. Step4] Verify that the NetworkInfo  object is not empty and also check if the device is connecte to the devic...

Create Tablayout with Viewpager in Android. Tabs in Android. Tablayout with Fragments and Viewpager

Image
Useful video :  https://youtu.be/528-udFokS4 TABLAYOUT WITHOUT VIEWPAGER : https://code8808.blogspot.com/2020/07/create-tablayout-without-viewpager-in.html ---------------------- ----------------------- ------------ ----------------------- ------------ ------------- NOTE : A new way of implementing viewpager2  https://developer.android.com/training/animation/screen-slide-2 https://www.youtube.com/watch?v=iJpB5ju3tN8 Adapter is now "FragmentStateAdapter" <? xml version ="1.0" encoding ="utf-8" ?> <androidx.constraintlayout.widget.ConstraintLayout 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 =".MainActivity" > <com.google.android.material.tabs.TabLayout ...

Recyclerview in Android . RecyclerView

Image
Useful Blogs :  https://guides.codepath.com/android/using-the-recyclerview Layoutinflator & dynamic UI creation -  https://stackoverflow.com/questions/3477422/what-does-layoutinflater-in-android-do#:~:text=LayoutInflater%20is%20a%20class%20used,another%20is%20dynamic%20or%20programmatically. Useful Videos :  https://www.youtube.com/watch?v=9tD6uCOdvmY&list=PLirRGafa75rSMDp5bORq_eHjMLKqJ2EYO https://www.youtube.com/watch?v=9rcrYFO1ogc (Recyclerview with Cardview) -  https://www.youtube.com/watch?v=Urpt8m6Uijw&list=PLirRGafa75rSMDp5bORq_eHjMLKqJ2EYO&index=2 -------------------------------------------------------------------------------------------- RecyclerView is the predessor of GridView and Listview RecyclerView takes less mememory space to display large amount of data. Recycler view calculates the size of the ROW size & determines how many rows can be fit inside the screen. Depending on the screen size , recycler view creates only that much of t...