横向listview的item的事件 解决方案

看外国人解决办法
Finally i changed my approach to add horizontal images inside list view.

Before i tried by created new Adapter and inflating it , now i creating DYNAMIC TABLE LAYOUT and added images to it.

Place where i changed :
if (mediaList.size() > 0) {
   for (int i = 0; i < mediaList.size(); i++) {
       mediaInside = mediaList.get(i);
       LinearLayout row = (LinearLayout) inflater
                    .inflate(R.layout.inbox_horizontal_row,
                            dynamicMediaTable, false);
       final ImageView mediaImage = (ImageView) row
                    .findViewById(R.id.media_image_view);
       final RelativeLayout likeComment = (RelativeLayout) row
                    .findViewById(R.id.like_comment_layout);
       mediaImage.setImageDrawable(icon);

       dynamicMediaTable.addView(row);
       likeComment.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    Log.v("Media Id Clicked", mediaImage.getTag()
                }
        });
    }

}

My Main XML :
<RelativeLayout
    android:id="@+id/image_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="65dp"
    android:layout_marginTop="10dp" >

    <HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none" >

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/dynamic_table_row"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" />
        </TableLayout>
    </HorizontalScrollView>

    <ImageView
        android:id="@+id/inbox_reply_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="5dp"
        android:src="@drawable/replybutton" />
</RelativeLayout>

My Dynamic 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="horizontal" >
    <ImageView
        android:id="@+id/media_image_view"
        android:layout_width="180dp"
        android:layout_height="240dp" />
</LinearLayout>

猜你喜欢

转载自luzefengcool.iteye.com/blog/1673700
今日推荐