N
N
nikita_chiru2016-05-17 14:56:27
Android
nikita_chiru, 2016-05-17 14:56:27

How to get the text from the list?

I have a list created via an adapter and a template file... how to get and pass text or an image via putEXTRA
Here is the text of the template

<LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="90dp"
            android:layout_height="90dp"
            android:src="@drawable/saiman"
            android:clickable="false" />
        <LinearLayout
            android:id="@+id/linearLayout2"
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:orientation="vertical"
            android:weightSum="1">

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="top|left"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge"
                />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:text="textview"
                />

Here is the text created list
1) additional adapter
public class ListData{
    String title;//Название товара
    int price;//Цена товара
    int image;

    ListData(String _title, int _price, int _image){
        title= _title;
        price= _price;
        image= _image;


    }
}

2) Create a list
public View getView(int position, View convertView, ViewGroup parent) {
        ListData p=((ListData) getItem(position));
        View v = inflater.inflate(R.layout.item, parent, false);
        ((TextView) v.findViewById(R.id.textView1)).setText(p.title);
        ((TextView) v.findViewById(R.id.textView2)).setText(p.price+"руб");
        ((ImageView) v.findViewById(R.id.imageView1)).setImageResource(p.image);
        return v;
    }

Specifically, you need to get the text from R.id.textView1, R.id.textView2 and R.id.imageView1 and pass it to another class

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Gamega, 2016-05-17
@gadfi

intent1.putExtra("name",getText(R.id.textView1).toString() );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question