Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Showing Android GridView using PageRenderer

$
0
0

Hi!
I try to show GridView in the ContentPage, using such way:
`
public class Page1Render : Xamarin.Forms.Platform.Android.PageRenderer
{
public Page1Render()
{
}

    protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
    {
        base.OnElementChanged(e);

        GridView grd = new GridView(this.Context);
        grd.SetColumnWidth(100);
        grd.StretchMode = StretchMode.StretchColumnWidth;
        grd.SetGravity(GravityFlags.Center);
        grd.Adapter = new ImageAdapter(this.Context);
        grd.ItemClick += (sender, args) => Toast.MakeText(this.Context, args.Position.ToString(), ToastLength.Short).Show();

        this.AddView(grd, ViewGroup.LayoutParams.FillParent);
    }
}

, but I dont see GridView on the screen. Is it right way to add gridview on the ContentPage?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>