2

我怎样才能创造这样的东西?

我想让“选择的图像”作为主视图,然后在底部有时间线效果;类似 a 的东西Gallery会起作用,但已被弃用

我在想 aHorizontalScrollView在底部,但这会view正确回收 s 吗?我可以在这里实现ViewHolder模式吗?

怎么样StackView?我发现了这个:http ://www.gdgankara.org/2012/03/25/stackview-non-widget-sample/这可能很酷,但我在网上找不到很多关于StackViews 的东西,所以我我想知道它实施了多少?

在此处输入图像描述

4

1 回答 1

0

我通过使用 MUKESH YADAV 的自定义水平解决了ListView这个问题

我将他的HorizontalImageAdapter.java班级改为使用CursorAdapter.

我的解决方案在这里:

public class HorizontalImageAdapter extends CursorAdapter  {

    //...some initialization here

     public HorizontalImageAdapter(Context context, Cursor c, int count) {
            super(context, c, true);

            this.context = (Activity) context;
            this.count = count;
            this.cursor = c;
            inflater = LayoutInflater.from(context);

            cursor.moveToFirst();           
        }

     private static class ViewHolder {
            public ImageView imageview;
            public TextView textview;
            public ImageView imageviewvideo;

        }

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

         ViewHolder holder = null;       
         cursor.moveToPosition(position);

         if (convertView == null) {
             Log.d(TAG, "converView == null <<<<<<<<<<<<<<<<<<<<<<<<");

             convertView = inflater.inflate(R.layout.activity_media_items, null);
             holder = new ViewHolder();

             holder.textview = (TextView) convertView.findViewById(R.id.tv_details_title);
             holder.imageview = (ImageView) convertView.findViewById(R.id.iv_details_resource_image);
             holder.imageviewvideo = (ImageView) convertView.findViewById(R.id.iv_details_resource_video);

             convertView.setTag(holder);

          } else {
              Log.d(TAG, "converView != null >>>>>>>>>>>>>>>>>>>>>>>>");                
          }

            //get the type of the item      
            type = cursor.getString(cursor.getColumnIndex(DatabaseHelper.FIELD_ITEM_TYPE));

            if(type.equalsIgnoreCase("text")){
            //handle for text item  

            }

            if(type.equalsIgnoreCase("image")){
            //handle for image item 

            }

            if(type.equalsIgnoreCase("video")){
            //handle for video item

            }
            return convertView;     
     }       

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        ViewHolder holder = (ViewHolder) view.getTag();

        String title = cursor.getString(cursor.getColumnIndex(DatabaseHelper.FIELD_TITLE));
        String fileName = cursor.getString(cursor.getColumnIndex(DatabaseHelper.FIELD_RESOURCE));

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        ViewHolder holder = new ViewHolder();
        View eachitem = inflater.inflate(R.layout.activity_media_items, parent, false);

        holder.textview = (TextView) eachgrid.findViewById(R.id.tv_details_title);
        holder.imageview = (ImageView) eachgrid.findViewById(R.id.iv_details_resource_image);
        holder.imageviewvideo = (ImageView) eachgrid.findViewById(R.id.iv_details_resource_video);

        eachgrid.setTag(holder);

        return eachitem;        
    }
}

和 XML:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@android:color/black" >

    <ImageView
        android:id="@+id/selected_imageview"
        android:layout_width="@dimen/exhibit_item_width"
        android:layout_height="@dimen/exhibit_item_height"
        android:layout_gravity="center"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        android:maxHeight="@dimen/exhibit_item_height"
        android:maxWidth="@dimen/exhibit_item_width"
        android:src="@drawable/logo" />

    <RelativeLayout
        android:id="@+id/gallery_relative_layout"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/exhibit_items_height"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="horizontal" >

        <com.example.testdatabase2.HorizontalView
            android:id="@+id/gallery"
            android:layout_width="match_parent"
            android:layout_height="@dimen/exhibit_items_height"
            android:layout_centerHorizontal="true"
            android:smoothScrollbar="true"
            android:spacing="20dip" >
        </com.example.testdatabase2.HorizontalView >
    </RelativeLayout>        
</LinearLayout>
于 2013-08-13T08:22:29.647 回答