【问题标题】:Horizontal Listview Not Working from github水平列表视图不适用于 github
【发布时间】:2016-04-01 13:12:20
【问题描述】:

我正在使用 GitHub 库来制作位图的水平滚动视图,但这不起作用(也尝试过用于文本视图)。

这个库的基本代码我用is this.

这是我正在使用的自定义 Arrayadapter:

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;
    }
}

这是专辑类:

public class AlbumArtclass {
    private Bitmap Albumartforthis=null;


    public AlbumArtclass(Bitmap backgroundColor) {
        Albumartforthis = backgroundColor;

    }
    public Bitmap getAlbumARt() {
        return Albumartforthis;
    }

}

这是我使用的布局(我的 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>

我遇到的问题是列表视图没有显示任何数据。

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

Listview 显示黑屏。

【问题讨论】:

    标签: android xml listview github android-listview


    【解决方案1】:

    尝试在滚动视图中使用 android:fillViewport="true"

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多