I am having probelmas trying to show a list inside of a fragment, inside activity_main I have the following code, that for the moment it only shows a textview with a phrase and if I keep it that way the menu I am using works for me (template of android menu below) and I can navigate from one fragment to another, but if I change the textview to a list when I try to change from one fragment to another, it does not work. The list is visible but not the content I have in the other fragments, and my The main fragment has to show the list.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layouts"
android:layout_alignParentTop="true"
android:orientation="horizontal">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:text="TextView" />
<!--<ListView-->
<!--android:layout_width="fill_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:paddingTop="60dp"-->
<!--android:paddingBottom="60dp"-->
<!--android:layout_marginLeft="20dp"-->
<!--android:layout_marginRight="20dp"-->
<!--android:divider="@null"-->
<!--android:id="@+id/listview">-->
<!--</ListView>-->
</LinearLayout>
</RelativeLayout>
Lists: Java of a fragment, the 4 fagments by the omentum are identical
public class Lista extends Fragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_listas, container, false);
}
}
fragment_listsa.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"
tools:context=".Agendas">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Agendas"
android:textSize="20sp"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:id="@+id/textView6"
/>
</RelativeLayout>