Creating Sliding Tab Layout Using Xamarin Android

**Hi I am getting the list from stored procedure. The List content To display one by one using sliding layout. But It's unable to showing the content. **

namespace TreePager
class TempPagerAdapter : PagerAdapter
Activity context;
public List treeCatalog;
public TempPagerAdapter(Activity context, List treeCatalog)
this.context = context;
this.treeCatalog = treeCatalog;

    public override int Count
        get { return treeCatalog == null ? -1 : treeCatalog.Count; }

    public override Java.Lang.Object InstantiateItem(ViewGroup container, int position)
   var item = treeCatalog[position];
        View view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.tempview, container, false);
        TextView txtTitle = container.FindViewById<TextView>(Resource.Id.txtlyricstemp);
        string Lyricspara= item.Lyrics;
        txtTitle.Text = Lyricspara;
        return view;

   //View view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.tempview, container, false);
        //TextView txtTitle = view.FindViewById<TextView>(Resource.Id.txtlyricstemp);
        //int pos = position + 1;
        //txtTitle.Text = pos.ToString();
        //return view;

    public override void DestroyItem(View container, int position, Java.Lang.Object view)
        var viewPager = container.JavaCast<ViewPager>();
        viewPager.RemoveView(view as View);

    public override bool IsViewFromObject(View view, Java.Lang.Object obj)
        return view == obj;

    public override Java.Lang.ICharSequence GetPageTitleFormatted(int position)
        return new Java.Lang.String(treeCatalog[position].Lyrics);



I can assign into number to the page it's working. But the get value from list it's not working properly. If anyone resolve my issue.


  • MohanrajManickamMohanrajManickam USMember ✭✭

    My problem resolved. I made a mistake to the below line.

          TextView txtTitle = view.FindViewById<TextView>(Resource.Id.txtlyricstemp);

    Now it's working properly...

  • jezhjezh Member, Xamarin Team Xamurai

    Congrats, it’s really efficient to solve the problem.

Sign In or Register to comment.