Hello I managed to reproduce the code from this tutorial https://www.youtube.com/watch?v=HrLLnoa9Zd4&index=32&list=WL&t=330s.
But then I decided to add something simple like a button to the left slide that changes its text. I created a new activity with SetContentView(Resource.Layout.Left);
and wrote the click event to the button. When I start the program ,though, I click on the button and nothing happens. I figured out that the activity is actually not called and what I see is only the layout.
My question is if there is a way to call the activity that I wrote when I slide to the left?
main layout
<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">
<com.jkb.slidemenu.SlideMenuLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slideMenuLayout1"
app:contentToggle="true"
app:contentAlpha="0.5"
app:parallax="false"
app:slideMode="both">
<include layout="@layout/Left" />
<include layout="@layout/Right" />
<include layout="@layout/MainView" />
</com.jkb.slidemenu.SlideMenuLayout>
</RelativeLayout>
left layout
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/leftBtn" />
<TextView
android:text="Slide Left"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/leftText" />
left activity
Button btn = FindViewById<Button>(Resource.Id.leftBtn);
TextView text = FindViewById<TextView>(Resource.Id.leftText);
btn.Click += (sender, e) => { text.Text = "text is chaged"; };
I got. I can use fragments
instead of include
.
The main.axml will look like this
<com.jkb.slidemenu.SlideMenuLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/slideMenuLayout1"
app:contentToggle="true"
app:contentAlpha="0.5"
app:parallax="false"
app:slideMode="both">
<fragment
class="NameSpace.FragmentName" //it is important to write the namespace and gragment name
android:layout = "@layout/Left" //here you choose the layout you want to render
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/RightFragment" />
//repeat the same for the Right and Main view
</com.jkb.slidemenu.SlideMenuLayout>
And the fragment.cs you just need this
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
View view = inflater.Inflate(Resource.Layout.YourLayout, container, false);
}