Horizo​​ntalListView-如何获取图像视图源

时间:2018-08-27 13:07:15

标签: android

我希望有人能给我提示如何解决此问题:

我的布局包含垂直滚动视图和Horizo​​ntalListView。 我可以在垂直列表中上下滚动并水平滚动以查看图像。当我单击水平列表中的图像时,我要显示完整图像。问题是当在horizo​​ntalListView上单击图像时,我不知道如何获取图像源值。例如

/storage/emulated/0/ItineraryPlanner/imag-20180825-0.jpg

我从下面找到了用于处理水平列表视图的示例

https://github.com/MeetMe/Android-HorizontalListView/blob/master/AndroidHorizontalListView/src/com/meetme/android/horizontallistview/HorizontalListView.java

我需要从onSingleTapConfirmed方法获取图像值项。任何人都可以建议。下面是我的布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:widget="http://schemas.android.com/apk/res-auto"
    android:id="@+id/itineary_row_layout"
    android:scrollbarStyle="insideInset"
    android:fadeScrollbars="true"
    android:scrollbarSize="10dip"
    android:fitsSystemWindows="true"
    android:weightSum="1.0"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/product_list_item_bg"
        android:padding="@dimen/space1"
        android:textSize="18dip"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:id="@+id/row_1">

            <TextView
                android:id="@+id/icon_delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0.05"
                android:drawableLeft="@drawable/ic_delete_grey"
                android:drawablePadding="@dimen/space1"
                android:paddingLeft="2dp"
                android:paddingTop="7dp"
                android:textColor="@color/colorPrimaryTrans"
                fontPath="fonts/reg.otf"
                tools:ignore="MissingPrefix"
                android:layout_gravity="right" />
        </LinearLayout>

        <View
            android:id="@+id/divider_line__header"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_below="@+id/row_1"
            android:layout_marginTop="10dp"
            android:background="@color/view_divider_color" />


        <LinearLayout
            android:id="@+id/layout_horizontal"
            android:layout_width="match_parent"
            android:layout_height="120dp"
            android:layout_marginLeft="5dp"
            android:orientation="horizontal"
            android:visibility="visible"
            android:layout_below="@+id/row_6"  >

            <au.com.klau.itineraryplanner.HorizontalListView
                android:id="@+id/list_images"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clickable="true"
                android:gravity="center" >
            </au.com.klau.itineraryplanner.HorizontalListView>
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>


@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
    unpressTouchedChild();
    OnItemClickListener onItemClickListener = getOnItemClickListener();

    final int index = getChildIndex((int) e.getX(), (int) e.getY());

   if (index >= 0 && !mBlockTouchAction) {
        View child = getChildAt(index);
        int adapterIndex = mLeftViewAdapterIndex + index;

        Object obj = HorizontalListView.this.mAdapter.getItemId(adapterIndex);
        Object obj1 = HorizontalListView.this.mAdapter.getItemViewType(adapterIndex);

        System.out.println("HorizontalListView.onSingleTapConfirmed - index >= 0 : getItemId obj[" + obj.toString() + "] | getItemViewType=>obj1.toString()[" + obj1.toString() + "]");


        if (onItemClickListener != null) {
            onItemClickListener.onItemClick(HorizontalListView.this, child, adapterIndex, mAdapter.getItemId(adapterIndex));
            return true;
        }
    }

    if (mOnClickListener != null && !mBlockTouchAction)
    {
        mOnClickListener.onClick(HorizontalListView.this);

    } 

    return false;
}

0 个答案:

没有答案