使用Etsy的StaggeredGridView,有问题

时间:2015-01-09 03:54:42

标签: android android-fragments

在片段中使用Etsy's staggeredGridView,当我更快速地将视图变成幻灯片时,项目图像视图也会发生变化(滑动后我第一次看到的是不同的。) 另一个问题,在ItemLayout中有两个imageview,它只显示一个图像。
我不知道为什么?

<!-- this is my item_layout -->

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="2dip"
        android:background="@drawable/memory_list_item_border"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@+id/memory_list_item_frame"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <com.tripbe.chanzhi.widget.ScaleImageView
                    android:id="@+id/memory_list_item_image"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

                <FrameLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="5dp"
                    android:background="@drawable/personal_info_top_head_lie" >

                    <com.tripbe.chanzhi.widget.ScaleImageView
                        android:id="@+id/memory_list_item_head"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:layout_gravity="center_vertical|center_horizontal"
                        android:background="@drawable/personal_info_normal_head" />
                </FrameLayout>

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBottom="@+id/memory_list_item_image"
                    android:layout_centerHorizontal="true"
                    android:padding="10dip" >

                    <ImageView
                        android:id="@+id/horizontal_item_love"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/memory_zan" />

                    <RelativeLayout
                        android:layout_width="50dip"
                        android:layout_height="30dip" >

                        <com.etsy.android.grid.util.DynamicHeightTextView
                            android:id="@+id/memory_list_item_zan_num"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:text="12"
                            android:textColor="@color/white"
                            android:textSize="16sp" />
                    </RelativeLayout>
                </RelativeLayout>
            </RelativeLayout>
        </FrameLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="7dip"
                android:background="@drawable/memory_list_item_local" />

            <com.etsy.android.grid.util.DynamicHeightTextView
                android:id="@+id/memory_list_item_location"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="7dip"
                android:textColor="@color/black"
                android:textSize="16sp" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>


<!-- this is adapter code-->

public class MemoryListAdapter extends ArrayAdapter<Object> {

    private ArrayList<Memory>         list;

    private final LayoutInflater      mLayoutInflater;
    private TripbeDefaultImageManager manager;

    public MemoryListAdapter(Context context, int imageid, int headid) {
        super(context, imageid, headid);
        mLayoutInflater = LayoutInflater.from(context);
        manager = TripbeDefaultImageManager.getInstance();
    }

    public void setList(ArrayList<Memory> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.memory_list_item, null);
            holder = new ViewHolder();
            holder.memory_list_head = (ImageView) convertView
                .findViewById(R.id.memory_list_item_image);
            holder.memory_list_image = (ScaleImageView) convertView
                .findViewById(R.id.memory_list_item_image);
            holder.memory_list_zan_num = (DynamicHeightTextView) convertView
                .findViewById(R.id.memory_list_item_zan_num);
            holder.memory_list_location = (DynamicHeightTextView) convertView
                .findViewById(R.id.memory_list_item_location);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Memory memory = list.get(position);
        holder.memory_list_zan_num.setText(memory.like_count);
        if (memory.dest != null) {
            holder.memory_list_location.setText(memory.dest.name);
        }
        //  manager.requestImage(memory.user.getAvatar(), holder.memory_list_head);
        return convertView;
    }

    static class ViewHolder {
        ScaleImageView        memory_list_image;
        ImageView             memory_list_head;
        DynamicHeightTextView memory_list_zan_num;
        DynamicHeightTextView memory_list_location;
    }
}

<!-- this is the code in fragment  using adapter  -->


public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);

        loadingDialog = new LoadingDialog(getActivity());
        loadingDialog.show();
        if (adapter == null) {
            adapter = new MemoryListAdapter(getActivity(),R.id.memory_list_item_image,R.id.memory_list_item_head);
        }
        if (data_list == null) {
            data_list = new ArrayList<Memory>();
        }
        if (getArguments().getString("destid") != null) {
            destid = getArguments().getString("destid");
            MemoryListController.getInstance().requestMemoryList(destid,
                    record_start + "", null);
        } else {
            roadid = getArguments().getString("roadid");
            MemoryListController.getInstance().requestMemoryList(null,
                    record_start + "", roadid);
        }
        adapter.setList(data_list);
        memory_grid.setAdapter(adapter);
        memory_grid.setOnScrollListener(this);
        memory_grid.setOnItemClickListener(this);

    }

请帮帮我。请

0 个答案:

没有答案