Android 在RecyclerView中获取选定的TextView值

Android 在RecyclerView中获取选定的TextView值,android,android-studio,android-recyclerview,Android,Android Studio,Android Recyclerview,我正在尝试从RecyclerView中的所选项目中获取TextView值。我的RecyclerView布局文件有两个TextViews,一个用于名称,另一个用于日期,如您在此处所见: <TextView android:id="@+id/layout_recyclerview_view_list_name" android:layout_width="wrap_content" android:layout_height="wrap_content" and

我正在尝试从
RecyclerView
中的所选项目中获取
TextView
值。我的
RecyclerView
布局文件有两个
TextView
s,一个用于名称,另一个用于日期,如您在此处所见:

<TextView
    android:id="@+id/layout_recyclerview_view_list_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:textStyle="bold"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/layout_recyclerview_view_list_date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignStart="@+id/layout_recyclerview_view_list_name"
    android:layout_alignLeft="@+id/layout_recyclerview_view_list_name"
    android:layout_below="@+id/layout_recyclerview_view_list_name" />
这是启动我前面提到的其他活动的
onClick
事件:

recyclerView.addOnItemTouchListener(
            new ListsRecyclerViewListListener(this,
                    new ListsRecyclerViewListListener.OnItemClickListener() {
                        @Override
                        public void onItemClick(View view, int position) {
                            Intent intent = new Intent(getBaseContext(), ListsEditListActivity.class);
                            Bundle bundle = new Bundle();

                            bundle.putString("name", /*this is where I need to set the value*/);
                            intent.putExtras(bundle);

                            startActivity(intent);
                        }
                    })
    );
这是为
列表
回收视图
设置值的类:

List<ListsRecyclerViewList> list;

public ListsRecyclerViewListAdapter(List<ListsRecyclerViewList> list) {
    this.list = list;
}

@Override
public ListsRecyclerViewListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_recyclerview_view_list, parent, false);
    ListsRecyclerViewListViewHolder viewHolder = new ListsRecyclerViewListViewHolder(view);

    return viewHolder;
}

@Override
public void onBindViewHolder(ListsRecyclerViewListViewHolder holder, int position) {
    holder.name.setText(list.get(position).getName());
    holder.date.setText(list.get(position).getDate());
}

@Override
public int getItemCount() {
    return list.size();
}

public static class ListsRecyclerViewListViewHolder extends RecyclerView.ViewHolder {
    TextView name;
    TextView date;

    public ListsRecyclerViewListViewHolder(View view) {
        super(view);

        this.name = (TextView) view.findViewById(R.id.layout_recyclerview_view_list_name);
        this.date = (TextView) view.findViewById(R.id.layout_recyclerview_view_list_date);
    }
}
public String name;
public String date;

public ListsRecyclerViewList(String name, String date) {
    this.name = name;
    this.date = date;
}

如何从
RecyclerView
中的所选项目中获取名称字段并将其传递给其他活动?有什么建议吗?

您可以使用
viewHolder.name.getText(list.get(position.name)
。这将从变量
position

中存储位置的
TextView
中获取文本。您应该在触摸回收视图时获取视图,并使用该视图的引用以该方法初始化两个文本视图。从中你可以得到这两个文本视图的值,你能详细说明一下吗?