如何在RecyclerView中单击HEADER_VIEW标题时启动新活动显示IT中的项目

时间:2018-05-10 13:49:24

标签: android android-recyclerview recycler-adapter

the documentation

Activty one 中我有 RecyclerView 来查看:

  • HEADER_VIEW
  • ITEM_VIEW

Header_view.xml

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

<android.support.v7.widget.CardView
    android:id="@+id/cv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="3dp"
    android:elevation="3dp">

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

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:clickable="true"
            android:src="@mipmap/ic_launcher" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_below="@id/imageView"
            android:background="#f5fff2">

            <TextView
                android:id="@+id/tv_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"

                android:layout_marginBottom="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="10dp"
                android:text="name"
                android:textAlignment="center"
                android:textColor="#FF20C200"
                android:textSize="18sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/new_price"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/old_price"
                android:layout_marginRight="5dp"
                android:layout_marginStart="5dp"
                android:layout_toEndOf="@+id/old_price"
                android:text="480.00 DA"
                android:textColor="#FF65C2FD"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/old_price"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/tv_name"
                android:layout_marginBottom="10dp"
                android:layout_marginRight="5dp"
                android:layout_marginStart="5dp"
                android:text="250.00 DA"
                android:textAlignment="center"
                android:textColor="#F50057" />

            <ImageButton
                android:id="@+id/overflow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignTop="@+id/new_price"
                android:layout_marginEnd="5dp"
                android:layout_marginLeft="5dp"
                android:background="?attr/selectableItemBackgroundBorderless"
                app:srcCompat="@drawable/ic_more_vert_black_24dp" />
        </RelativeLayout>

    </RelativeLayout>
</android.support.v7.widget.CardView>

</LinearLayout>

Item_view.xml

@Override
  public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {

    //Context context = mContextWeakReference.get();

    if (mContext == null) {
        return;
    }

    if (SECTION_VIEW == getItemViewType(position)) {

        final SectionViewHolder sectionViewHolder =(SectionViewHolder)holder;

        GroupTitleModel sectionItem = ((GroupTitleModel) mUsersAndSectionList.get(position));



        sectionViewHolder.title.setText(sectionItem.title);
        sectionViewHolder.more.setText(sectionItem.moreSection);

        sectionViewHolder.more.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View view) {


         // I TRY TO DO IT HERE BUT NO THINGS



            }
        } );


        return;
    }

我创建了适配器并且工作正常。

我的问题是:

我需要点击更多TextView 在HEADER_VIEW新活动开始时

具有特定的指导性Itemes。

我的尝试:

适配器正好位于 onBindViewHolder

Sub SearchReplace()

    Dim regEx As Object
    Dim qtext As String
    Dim html_input As String

    ' set up regex
    Set regEx = CreateObject("VBScript.RegExp")
    regEx.Pattern = "\(\[aA\]\)ttorney-at-law"
    regEx.Global = True

    ' input and replacement text
    qtext = "\(\[aA\]\)ttorney-at-law"
    html_input = "\1ttorney at law"

    ' do replace
    qtext = regEx.Replace(qtext, html_input)

End Sub

0 个答案:

没有答案