今天做了什么:

完成了关于识图后传递回来数据到listview 和 社区listview的适配器的编写

package com.hui.testend.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hui.testend.R;
import com.hui.testend.mytool.ImageUtil;

import java.util.Base64;
import java.util.List;

public class MyAdapter extends BaseAdapter {
private List<ItemBean> MyList;
private LayoutInflater mlayoutInflater;
private Context mContext;

public MyAdapter() {
}

public MyAdapter(Context mContext, List<ItemBean> MyList){
this.mContext=mContext;
this.MyList=MyList;
mlayoutInflater=LayoutInflater.from(mContext);
}

@Override
public int getCount() {
return MyList.size();
}

@Override
public Object getItem(int position) {
return MyList.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView=mlayoutInflater.inflate(R.layout.layout_item,parent,false);
ImageView imageView=convertView.findViewById(R.id.Iv_img);
TextView tv_title=convertView.findViewById(R.id.tv_title);
TextView tv_content=convertView.findViewById(R.id.tv_content);
ItemBean itemBean=MyList.get(position);
imageView.setImageBitmap(ImageUtil.base64ToImage(Base64.getEncoder().encodeToString(itemBean.getImg())));
tv_title.setText(itemBean.getTitle());
tv_content.setText(itemBean.getContent());
return convertView;
}
}
package com.hui.testend.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hui.testend.R;
import com.hui.testend.mytool.ImageUtil;

import java.util.Base64;
import java.util.List;

public class MyAdapter1 extends BaseAdapter {
private List<ItemBean> MyList;
private LayoutInflater mlayoutInflater;
private Context mContext;

public MyAdapter1() {
}

public MyAdapter1(Context mContext, List<ItemBean> MyList){
this.mContext=mContext;
this.MyList=MyList;
mlayoutInflater=LayoutInflater.from(mContext);
}

@Override
public int getCount() {
return MyList.size();
}

@Override
public Object getItem(int position) {
return MyList.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView=mlayoutInflater.inflate(R.layout.layout_item,parent,false);
ImageView imageView=convertView.findViewById(R.id.Iv_img);
TextView tv_title=convertView.findViewById(R.id.tv_title);
TextView tv_content=convertView.findViewById(R.id.tv_content);
ItemBean itemBean=MyList.get(position);
imageView.setImageBitmap(itemBean.getImgs());
tv_title.setText(itemBean.getTitle());
tv_content.setText(itemBean.getContent());
return convertView;
}
}

遇到了什么困难:

 

明天准备做什么:

继续完成作业

代码量 150行

时间 1小时