Answer the question
In order to leave comments, you need to log in
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"
/>
public class ListData{
String title;//Название товара
int price;//Цена товара
int image;
ListData(String _title, int _price, int _image){
title= _title;
price= _price;
image= _image;
}
}
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question