Answer the question
In order to leave comments, you need to log in
How to add an image to the database or a link to it?
does the adapter need to be modified?
mData.add(new ListData("hello ",299,R.drawable.alkap ));
mData.add(new ListData("карка " ,9,R.drawable.dakota ));
mData.add(new ListData("лалка " ,99,R.drawable.saiman ));
public void setContentView(View contentView, int position, HorizontalScrollView parent) {
ListData p=((ListData) getItem(position));
TextView tv = (TextView)contentView.findViewById(R.id.textView2);
tv.setText(p.price+"руб");
TextView tv1 = (TextView)contentView.findViewById(R.id.tv);
tv1.setText(p.title);
ImageView tv3 = (ImageView) contentView.findViewById(R.id.imageView1);
tv3.setImageResource(p.image);
}
//实现setActionView方法
@Override
public void setActionView(final View contentView,final int position, final HorizontalScrollView parent) {
ListData p=((ListData) getItem(position));
final String name = p.title;
final int price = p.price;
final int image = p.image;
Answer the question
In order to leave comments, you need to log in
Well, if the picture is loaded from the web, then it's more logical to save the link in text form, and then use Picasso or Glide to load it. If pictures are resources, then store the resource identifier in the database (R.drawable.alkap, R.drawable.dakota... is an int value).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question