反正一定要新建一个布局(这里我不多说)
然后我们可以设置Adapt函数
ublic class KeyAdapt extends BaseAdapter {
private Context mcontext;
public KeyAdapt(Context context){
mcontext=context;
}
@Override
public int getCount() {
return 10;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
static class ViewHolder{
TextView key;
}
@SuppressLint("InflateParams")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder=null;
if (convertView == null) {
convertView = LayoutInflater.from(mcontext).inflate(R.layout.simple_adapter,null);
viewHolder=new ViewHolder();
viewHolder.key=convertView.findViewById(R.id.key_text);
convertView.setTag(viewHolder);
}else{
viewHolder= (ViewHolder) convertView.getTag();
}
viewHolder.key.setText("哈哈");
return convertView;
}
}
主界面使用
//关键词列表
key_list.setAdapter(new KeyAdapt(this));