0

I am using a GitHub library to make a horizontal scrollview of bitmaps but this is not working (aslo tried it for textviews).

The basic code in this library I used is this.

This is the custom Arrayadapter I am using:

public class CustomArrayAdapterForalbumart extends ArrayAdapter<AlbumArtclass> {
    private LayoutInflater mInflater;
    private Context mContext=null;
private List<AlbumArtclass> data=new Vector<AlbumArtclass>();
    public CustomArrayAdapterForalbumart(Context context, List<AlbumArtclass> totalalbumarts) {
        super(context, R.layout.custom_data_view, totalalbumarts);
        this.mContext=context;
        mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   this.data=totalalbumarts;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View row = convertView;
        Holder holder;

        if(row==null)
        {
            LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
            row = mInflater.inflate(R.layout.custom_data_view, parent,false);
            holder= new Holder();
           holder.abumartforeachclass=(ImageView) row.findViewById(R.id.Albumartforsonginpayeractivity);
           row.setTag(holder);
        }
        else
        {
            holder=(Holder) row.getTag();
        }
        AlbumArtclass mrb =data.get(position);

        holder.abumartforeachclass.setImageBitmap(mrb.getAlbumARt());

        return row;
        }

    /** View holder for the views we need access to */
    private static class Holder {
        public ImageView abumartforeachclass;
    }
}

This is Albumart class:

public class AlbumArtclass {
    private Bitmap Albumartforthis=null;


    public AlbumArtclass(Bitmap backgroundColor) {
        Albumartforthis = backgroundColor;

    }
    public Bitmap getAlbumARt() {
        return Albumartforthis;
    }

}

This is the layout I used (part of my XML):

<ScrollView 
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<com.androidhive.musicplayer.HorizontalListView
                android:id="@+id/HSVfoalbumarinplayeractivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

               </ScrollView>

custom_data_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<ImageView
    android:id="@+id/Albumartforsonginpayeractivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
</LinearLayout>

The problem I am geting is the listview is not showing any data.

public  void setupp(){
    adapterforalbumarts=new CustomArrayAdapterForalbumart(context, totalalbumarts);//totalalbumart contatins bitmaps
    HSVforimageGallery.setAdapter(adapterforalbumarts);         
    }

Listview is showing a black screen.

Animesh Mangla
  • 773
  • 7
  • 31

1 Answers1

1

try use android:fillViewport="true" inside your scroll view

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

<com.androidhive.musicplayer.HorizontalListView
                android:id="@+id/HSVfoalbumarinplayeractivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

</ScrollView>
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156