0

I have been stuck in this issue for almost 10 days, I have searched all over the Internet for a solution and I have tried them all but no one is working with me. Fragment1.cs

public override View OnCreateView(LayoutInflater inflater, ViewGroup 
 container, Bundle savedInstanceState)
  {
base.OnCreate(savedInstanceState);
View view = inflater.Inflate(Resource.Layout.my_layout, container, false);
add.Click += delegate
    {
        Fragment2 fragment2 = new Fragment2();
        FragmentTransaction ft = FragmentManager.BeginTransaction();
        ft.Replace(Resource.Id.content_frame, fragment2);
        ft.Commit();
     };
return view;
}

Fragment2.cs

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);
    View view = inflater.Inflate(Resource.Layout.fragment_lay, container, false);

    TextView txt = view.FindViewById<TextView>(Resource.Id.textView1);
    Button btn = view.FindViewById<Button>(Resource.Id.button1);
    listView = view.FindViewById<ListView>(Resource.Id.listView1);
    Toast.MakeText(Activity, "Fragment2 started", ToastLength.Short).Show();
    return view;
   }

my_layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame">
<TextView
    android:text="Text"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:id="@+id/total"
    android:textAlignment="center"
    android:textSize="30dp" />
<TextView
    android:text="Text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textchangevalue"
    android:textSize="33dip"
    android:textStyle="bold" />
<Button
    android:text="UPDATE"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/updatebtn" />
<Button
    android:text="ADD"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/addbtn" />
<ListView
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/portfoliolist"
    android:clickable="true" />

I have tried to change the layout of the Fragment1 by putting instead of <LinearLayout> a <FrameLayout> but also didn't worked. I have put a toast message in the Fragment2 and when I click the addbutton in the Fragment1, the toast message (which is in the fragment2) is showing which means that the fragment2 is starting fine but it's layout is not showing on the screen. Please help me to find a solution.

Wassim01
  • 189
  • 3
  • 11
  • Please don't repeat questions. Simply editing your original post with any new information you have, any new code you've tried, or an explanation of why any posted answers aren't working, will bump it to the top of the active queue. – Mike M. Jun 05 '18 at 00:07
  • @MikeM. I don't have any new information or updates on the issue. – Wassim01 Jun 05 '18 at 10:22

0 Answers0