怎么左选择器库android?

时间:2013-11-27 08:59:14

标签: android cursor gallery selecteditem

我有一个图片库,图库有一个默认选择器中心,请看图片

gallery1

我不需要左侧空间,因此我需要一个左选择器,如图所示:

gallery2

这是我的代码

 final  Gallery galay = (Gallery)findViewById(R.id.gallerylay);

 galay.setAdapter(new layoutAdapter(this));
galay.setSpacing(50);
  ..................

public class layoutAdapter extends BaseAdapter {

    private Context ctx;


    public layoutAdapter(Context c) {
        ctx = c;
    }

    @Override
    public int getCount() {

        return pics1.length;
    }

    @Override
    public Object getItem(int arg0) {

        return arg0;
    }

    @Override
    public long getItemId(int arg0) {

        return arg0;
    }

    @Override

    public View getView(int arg0, View arg1, ViewGroup arg2) {

        // Declare Variables
        TextView txtrank;
        TextView txtcountry;
        TextView txtpopulation;
        TextView imgflag;
        View itemView = (arg1 == null) ? View.inflate(ctx, R.layout.slide, null) :arg1;

        Gallery.LayoutParams innerLP = new Gallery.LayoutParams(250, 350);

        itemView.setLayoutParams(innerLP);
        itemView.setBackgroundResource(R.drawable.cadre1);
      txtrank=(TextView) itemView.findViewById(R.id.textView1);
      txtrank.setText(pics1[arg0]);
        return itemView;
    }}

我该怎么办呢?

1 个答案:

答案 0 :(得分:0)

您是否在XMl中实现了库视图?如果是,则设置

android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
android:columnWidth="70dp"
android:stretchMode="columnWidth"