電子信息工程專業(yè)畢設(shè)題目大全!基于單片機的!


最佳答案


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lingnet.app.tv.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.linkedList;
import java.util.List;
import java.util.Map;

import butterknife.ButterKnife;

public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.ViewHolder> {


private List<Map<String, String>> dataList = null;
Context context;

public MessageAdapter(Context context) {
this.context = context;
}

public void notifyDataSetChanged(List<Map<String, String>> dataList) {
if (dataList == null) {
this.dataList = new linkedList<>();

電子信息工程專業(yè)畢設(shè)題目大全!基于單片機的!

} else {
if (this.dataList == null) {
this.dataList = new linkedList<>();
}
this.dataList.addAll(dataList);
}
super.notifyDataSetChanged();
}

public void addData(List<Map<String, String>> dataList) {
if (dataList != null) {
this.dataList.addAll(dataList);
} else {
this.dataList = dataList;
}
}

//創(chuàng)建新View,被LayoutManager所調(diào)用
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout
.list_item_message, viewGroup, false);
ViewHolder vh = new ViewHolder(view);
return vh;
}

//將數(shù)據(jù)與界面進行綁定的操作
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
Map<String, String> data = dataList.get(position);
viewHolder.itemView.setTag(data);
}

//獲取數(shù)據(jù)的數(shù)量
電子信息工程專業(yè)畢設(shè)題目大全!基于單片機的!

@Override
public int getItemCount() {
int count = 0;
if (dataList != null) {
count = dataList.size();
}
return count;
}

//自定義的ViewHolder,持有每個Item的的所有界面元素
public static class ViewHolder extends RecyclerView.ViewHolder {

public ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
AutoUtils.autoSize(view);
}
}

}


電子信息工程專業(yè)畢設(shè)題目大全!基于單片機的!

網(wǎng)上報名
  • 姓名:
  • 專業(yè):
  • 層次: ??分?jǐn)?shù):
  • 電話:
  • QQ/微信:
  • 地址:

文中圖片素材來源網(wǎng)絡(luò),如有侵權(quán)請聯(lián)系644062549@qq.com刪除

轉(zhuǎn)載注明出處:http://www.tengyi66.com