Как отобразить изображение и текст из Cardview в другом действии onClick?

У меня есть пример приложения от exoguru, который содержит карточку, каждая карточка состоит из изображения и соответствующего текста. Теперь, как отобразить это изображение и текст в другом действии при нажатии на эту конкретную карточку?

Вот скриншот введите здесь описание изображения

Вот ViewHolder, который содержит onclick для просмотра карты

 class ViewHolder extends RecyclerView.ViewHolder{

        public ImageView imgThumbnail;
        public TextView tvNature;
        public TextView tvDesNature;

        public ViewHolder(View itemView) {
            super(itemView);
            imgThumbnail = (ImageView)itemView.findViewById(R.id.img_thumbnail);
            tvNature = (TextView)itemView.findViewById(R.id.tv_nature);
            tvDesNature = (TextView)itemView.findViewById(R.id.tv_des_nature);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

               v.getContext().startActivity(new Intent(v.getContext(),FullInfo.class));

                }
            });
        }
    }

Это макет действия, в котором должны отображаться изображение и текст.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="exoguru.lists.com.naturepics.FullInfo"
style="@style/Base.TextAppearance.AppCompat.Headline">

<ImageView
    android:id="@+id/iv_card"
    android:layout_width="match_parent"
    android:layout_height="140dp" />
<TextView
    android:id="@+id/tv_card_title"
    android:layout_below="@+id/iv_card"

    android:text="@string/hello_world" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:textSize="@dimen/abc_text_size_headline_material" />
<TextView
    android:id="@+id/tv_card"
    android:layout_below="@+id/tv_card_title"
    android:text="@string/hello_world" android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

These are the items from cardview

imgThumbnail = (ImageView)itemView.findViewById(R.id.img_thumbnail);   //The image
tvNature = (TextView)itemView.findViewById(R.id.tv_nature);    //The Title
tvDesNature = (TextView)itemView.findViewById(R.id.tv_des_nature);    //The Text

comment
очевидно, вам нужно передать URL-адрес изображения/изображения/идентификатора ресурса другому действию   -  person Selvin    schedule 30.04.2015
comment
@ Селвин да, но как?   -  person saurabh64    schedule 30.04.2015
comment
Почему за мой вопрос проголосовали? Постарайтесь объяснить. Я задал искреннее сомнение, и не так много вопросов, чтобы справиться с щелчком макета карты.   -  person saurabh64    schedule 30.04.2015


Ответы (1)


Вы должны передать URL-адрес изображения/идентификатор/.. в Intent.

Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("imageinfo", imageUrl);
startActivity(intent)

И по целевой деятельности

Bundle bundle = getIntent().getExtras();
String url = bundle.getString(“imageinfo”); 
person Sandro Machado    schedule 30.04.2015