Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackCodeReview/status/1304389227526983680
Bumped by Community user
deleted 43 characters in body; edited tags
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

I would like to ask if this is a bad idea. I have a spinner that it has a custom layout with 5 imageviews and 1 textview I. I would like to load it up with 80 rows, so it will display around 300 images, (all images are within the app) Is.

Is this a really bad idea? All

All the images are loaded this way:

I have a list with all the Resource Ids, and all the images are vector .xml files. I I tried to load the images with ffimageloading but as far as iI am concerned xmlXML are not supported. iI added ffimageloading.svg nubegt package and do some tests and the image was not displayed.

So what iI would like to ask: is this a bad idea? should iShould I find a library to load the images like ffimageloading or picasso? If yes, which one?

I would like to ask if this is a bad idea. I have a spinner that it has a custom layout with 5 imageviews and 1 textview I would like to load it up with 80 rows, so it will display around 300 images, (all images are within the app) Is this a really bad idea? All the images are loaded this way:

I have a list with all the Resource Ids, and all the images are vector .xml files. I tried to load the images with ffimageloading but as far as i am concerned xml are not supported. i added ffimageloading.svg nubegt package and do some tests and the image was not displayed.

So what i would like to ask: is this a bad idea? should i find a library to load the images like ffimageloading or picasso? If yes, which one?

I have a spinner that it has a custom layout with 5 imageviews and 1 textview. I would like to load it up with 80 rows, so it will display around 300 images (all images are within the app).

Is this a really bad idea?

All the images are loaded this way:

I have a list with all the Resource Ids, and all the images are vector .xml files. I tried to load the images with ffimageloading but as far as I am concerned XML are not supported. I added ffimageloading.svg nubegt package and do some tests and the image was not displayed.

So what I would like to ask: is this a bad idea? Should I find a library to load the images like ffimageloading or picasso? If yes, which one?

added 1960 characters in body
Source Link
CDrosos
  • 232
  • 1
  • 9
    class CustomAdapter : BaseAdapter
{
    private Context Context;
    private List<ButtonImagesTemplate> ButtonImagesTemplates;
    private LayoutInflater inflater;

    public CustomAdapter(Context context, List<ButtonImagesTemplate> ButtonImagesTemplates)
    {
        this.Context = context;
        this.ButtonImagesTemplates = ButtonImagesTemplates;
    }

    public override Object GetItem(int position)
    {
        return null;
    }

    public override long GetItemId(int position)
    {
        return position;
    }

    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        if (inflater == null)
        {
            inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
        }

        if (convertView == null)
        {
            convertView = inflater.Inflate(Resource.Layout.SpinnerTemplateModel, parent, false);
        }

        TextView nameTxt = convertView.FindViewById<TextView>(Resource.Id.TemplateNameTextView);
        ImageView img1 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView1);
        ImageView img2 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView2);
        ImageView img3 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView3);
        ImageView img4 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView4);
        ImageView img5 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView5);

        //BIND
        nameTxt.Text = ButtonImagesTemplates[position].Name;
    img1    var drawable = AppCompatResources.SetImageResourceGetDrawable(Context, ButtonImagesTemplates[position].Images[0]);
        img1.SetImageDrawable(drawable);
        img2.SetImageResource(ButtonImagesTemplates[position].Images[1]);
        img3.SetImageResource(ButtonImagesTemplates[position].Images[2]);
        img4.SetImageResource(ButtonImagesTemplates[position].Images[3]);
        img5.SetImageResource(ButtonImagesTemplates[position].Images[4]);

        return convertView;
    }

    public override int Count
    {
        get { return ButtonImagesTemplates.Count; }
    }
}

also the layout here:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="122sp">
    <LinearLayout 
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="50sp">
    <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView1" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView2" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView3" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView4" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView5" />
</LinearLayout>
    <TextView
style="@style/MyTextStyle"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="match_parent"
        android:layout_height="50sp"
        android:padding="10dp"
        android:layout_gravity="center"
        android:textAlignment="textStart"
        android:gravity="center"
        android:id="@+id/TemplateNameTextView" />
<View
            android:layout_width="match_parent"
            android:layout_height="@dimen/LineHeight"
            android:layout_marginTop="@dimen/LineMarginTopBottom"
            android:layout_marginBottom="@dimen/LineMarginTopBottom"
            android:layout_marginLeft="@dimen/ResourceOptionsMarginFromScreen"
            android:layout_marginRight="@dimen/ResourceOptionsMarginFromScreen"
            android:background="@color/dark_grey"/>
</LinearLayout>
    nameTxt.Text = ButtonImagesTemplates[position].Name;
    img1.SetImageResource(ButtonImagesTemplates[position].Images[0]);
    img2.SetImageResource(ButtonImagesTemplates[position].Images[1]);
    img3.SetImageResource(ButtonImagesTemplates[position].Images[2]);
    img4.SetImageResource(ButtonImagesTemplates[position].Images[3]);
    img5.SetImageResource(ButtonImagesTemplates[position].Images[4]);
    class CustomAdapter : BaseAdapter
{
    private Context Context;
    private List<ButtonImagesTemplate> ButtonImagesTemplates;
    private LayoutInflater inflater;

    public CustomAdapter(Context context, List<ButtonImagesTemplate> ButtonImagesTemplates)
    {
        this.Context = context;
        this.ButtonImagesTemplates = ButtonImagesTemplates;
    }

    public override Object GetItem(int position)
    {
        return null;
    }

    public override long GetItemId(int position)
    {
        return position;
    }

    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        if (inflater == null)
        {
            inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
        }

        if (convertView == null)
        {
            convertView = inflater.Inflate(Resource.Layout.SpinnerTemplateModel, parent, false);
        }

        TextView nameTxt = convertView.FindViewById<TextView>(Resource.Id.TemplateNameTextView);
        ImageView img1 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView1);
        ImageView img2 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView2);
        ImageView img3 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView3);
        ImageView img4 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView4);
        ImageView img5 = convertView.FindViewById<ImageView>(Resource.Id.TemplateImageView5);

        //BIND
        nameTxt.Text = ButtonImagesTemplates[position].Name;
        var drawable = AppCompatResources.GetDrawable(Context, ButtonImagesTemplates[position].Images[0]);
        img1.SetImageDrawable(drawable);
        img2.SetImageResource(ButtonImagesTemplates[position].Images[1]);
        img3.SetImageResource(ButtonImagesTemplates[position].Images[2]);
        img4.SetImageResource(ButtonImagesTemplates[position].Images[3]);
        img5.SetImageResource(ButtonImagesTemplates[position].Images[4]);

        return convertView;
    }

    public override int Count
    {
        get { return ButtonImagesTemplates.Count; }
    }
}

also the layout here:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="122sp">
    <LinearLayout 
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="50sp">
    <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView1" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView2" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView3" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView4" />
        <ImageView
        android:layout_width="50sp"
        android:layout_height="50sp"
        android:scaleType="centerInside"
        android:layout_weight="2"
        android:padding="10dp"
        android:layout_gravity="left"
        android:gravity="left"
        android:id="@+id/TemplateImageView5" />
</LinearLayout>
    <TextView
style="@style/MyTextStyle"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="match_parent"
        android:layout_height="50sp"
        android:padding="10dp"
        android:layout_gravity="center"
        android:textAlignment="textStart"
        android:gravity="center"
        android:id="@+id/TemplateNameTextView" />
<View
            android:layout_width="match_parent"
            android:layout_height="@dimen/LineHeight"
            android:layout_marginTop="@dimen/LineMarginTopBottom"
            android:layout_marginBottom="@dimen/LineMarginTopBottom"
            android:layout_marginLeft="@dimen/ResourceOptionsMarginFromScreen"
            android:layout_marginRight="@dimen/ResourceOptionsMarginFromScreen"
            android:background="@color/dark_grey"/>
</LinearLayout>
Source Link
CDrosos
  • 232
  • 1
  • 9

Loading 300 images on a custom spinner with images

I would like to ask if this is a bad idea. I have a spinner that it has a custom layout with 5 imageviews and 1 textview I would like to load it up with 80 rows, so it will display around 300 images, (all images are within the app) Is this a really bad idea? All the images are loaded this way:

    nameTxt.Text = ButtonImagesTemplates[position].Name;
    img1.SetImageResource(ButtonImagesTemplates[position].Images[0]);
    img2.SetImageResource(ButtonImagesTemplates[position].Images[1]);
    img3.SetImageResource(ButtonImagesTemplates[position].Images[2]);
    img4.SetImageResource(ButtonImagesTemplates[position].Images[3]);
    img5.SetImageResource(ButtonImagesTemplates[position].Images[4]);

I have a list with all the Resource Ids, and all the images are vector .xml files. I tried to load the images with ffimageloading but as far as i am concerned xml are not supported. i added ffimageloading.svg nubegt package and do some tests and the image was not displayed.

So what i would like to ask: is this a bad idea? should i find a library to load the images like ffimageloading or picasso? If yes, which one?