我有一个listView显示人物(一种学校社交媒体)的个人资料图片的地方,我将链接存储到SQL数据库中的那些图像及其名称和其他2个参数.
这是我的custom adapter:
class customAdapter extends ArrayAdapter<String> {
public customAdapter(Context context, String[] friends) {
super(context, R.layout.customrow, friends);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyDBHandler dbHandler = new MyDBHandler(getContext(), null, null, 1);
Product product;
LayoutInflater myinfl = LayoutInflater.from(getContext());
View customview = myinfl.inflate(R.layout.customrow, parent, false);
String singlefooditem = getItem(position);
TextView name = (TextView)customview.findViewById(R.id.rowText);
ImageView img = (ImageView)customview.findViewById(R.id.profilePic);
product = dbHandler.findProductName(singlefooditem);
try {
URL url = new URL(product.getImage());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true); …Run Code Online (Sandbox Code Playgroud)