so I created a listview that has 5 textviews in each row. the last textview is supposed to get me information about certain items upon being clicked. my listview's adapter has a context that corresponds to a fragment.
List<itemproperties> items;
itemdisplay context;
public homeadapter(itemdisplay context, List<itemproperties> items)
: base()
{
this.context = context;
this.items = items;
}
where itemdisplay is a fragment. and this is the code where I try to navigate to a new fragment when clicking on the textview
TextView textView = view.FindViewById<TextView>(Resource.Id.textView5);
Fragment1 fragment = new Fragment1();
if (!textView.HasOnClickListeners)
{
textView.Click += (o, e) =>
{
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.mainFrame, fragment)
.Commit();
};
}
all of the above codes are in my adapter. but I get an error because SupportFragmentManager doesn't seem to exist in adapters I guess. so my question is, how am I supposed to do this? thanks a lot in advance.
Do you want to achieve the result like following GIF?
If so, you Adatper need a
mainActivityattribute in constructor, then use following way inGetViewmethod.If you transfer to fragment layout, You found the previous listview stil existed. Please add
android:background="?android:windowBackground"in youractivity_main.xmland Fragment layout like following code.