I have extended 3 fragment in main activity..also how do i add recyclerview to display a list in one of my fragment.
Please help
I have extended 3 fragment in main activity..also how do i add recyclerview to display a list in one of my fragment.
Please help
Never mind you are begineer :) . Look first of all look how the fragment works.Fragment requires a activity . In activity you have to create framelayout and load or commit fragment in framelayout(Activity).
Now if you want to change any view in the activity you have to change it in fragment and call respective fragment in activity of change its view.
This means you have to add recyclerview in the activity but first off all you must add that fragment containing recyclerview to framelayout of the activity.
You are looking for something like this:
Note: Make sure you add this to your app gradle:
compile 'com.android.support:recyclerview-v7:23.4.0'
You have fragment1.java with layout fragment1.xml: fragment1.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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.support.v7.widget.RecyclerView
android:id="@+id/fragment1_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
Initialize this RecyclerView inside fragment1.java and write is adapter. For more on this, try these links: How to implement RecyclerView with CardView rows in a Fragment with TabLayout http://www.androidhive.info/2016/01/android-working-with-recycler-view/