I am able to bind and render images in recyclerview through adapter when binding adapter data from Activity in Xamarin.Android. but when i am binding it through fragment it's not throwing any exception and i try to debug it as well. but nothing worked.
How can i make them render through fragment in xamain.Android.
here is my binding code: Fragment Code :
using Android.OS;
using Android.Support.V4.App;
using Android.Views;
using Android.Widget;
using Android.Support.V7.Widget;
public class FragmentOne : Fragment
{
MyAdapter adapter = null;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.fragment_One, container, false);
//recycler view settings
recyclerView = view.FindViewById<RecyclerView>(Resource.Id.recyclerView);
recyclerView.SetLayoutManager(new LinearLayoutManager(view.Context, LinearLayoutManager.Vertical, false));
adapter = new MyAdapter(view.Context, SamepleData.persons.ToList());
adapter.ItemClick += Adapter_ItemClick;
recyclerView.SetAdapter(adapter);
return view;
}
}
here is my adapter code:
public MyAdapter(Context context, List<TestModel> data)
{
this.data = data;
this.context = context;
//this.context = Application.Context;
}
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
var vh = (MyViewHolder)holder;
vh.UserName.Text = data[position].FullName;
Stream stream = context.Assets.Open("Images/funImages/img1.png");
Drawable drawable = Drawable.CreateFromStream(stream, null);
vh.UserImage.SetImageDrawable(drawable);
}
recycleview axml code:
<LinearLayout
android:id="@+id/linlayout_ItemsRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:orientation="horizontal"
android:weightSum="100"
android:background="#F5F8F8">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:gravity="center_horizontal"
android:layout_marginRight="5dip">
<refractored.controls.CircleImageView
android:id="@+id/img_person"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#000" />
</LinearLayout>