2013-08-07 143 views
2

我该如何创建这样的东西?带有主视图的Android ListView - 时间轴效果 - 可能吗?

我想将“选定的图像”作为主视图,然后在底部显示时间线效果;像Gallery可以工作,但那已经是deprecated

我想HorizontalScrollView在底部,但会回收view正确吗?我可以在这里执行ViewHolder模式吗?

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

enter image description here

回答

0

我用水平ListView定制的解决了这个问题,通过MUKESH YADAV

我改变了他的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> 
+0

我还是想听到一些论点也许使用StackView,如果有人有话要说以上:) – marienke

+0

提及链接现在更改为: http://www.androiddevelopersolutions.com/2012/11/horizo​​ntal-listview-in-android-example.html –

相关问题