第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從 Activity 獲取價(jià)值到自定義數(shù)組適配器

從 Activity 獲取價(jià)值到自定義數(shù)組適配器

躍然一笑 2021-09-12 16:02:19
我正在創(chuàng)建聊天應(yīng)用程序。所以我想添加用戶從他的朋友那里得到的消息數(shù)量。為了表明我創(chuàng)建了自定義,Array adapter因?yàn)槲业牧斜硪晥D包含朋友姓名和notification textview.所以,我的 list_of_registerd_users 活動(dòng)中有數(shù)據(jù):如何將此數(shù)據(jù)發(fā)送到自定義array adapter類以設(shè)置通知視圖:自定義數(shù)組適配器類:public class CustomArrayAdapter extends ArrayAdapter<String> {    private Context mContext;    private int mRes;    private ArrayList<String> data;    private String numOfMsgs;    public CustomArrayAdapter(Context context, int resource,                              ArrayList<String> objects) {        super(context, resource, objects);        this.mContext = context;        this.mRes = resource;        this.data = objects;    }    @Override    public String getItem(int position) {        // TODO Auto-generated method stub        return super.getItem(position);    }    @Override    public View getView(int position, View convertView, ViewGroup parent) {        View row = convertView;        LayoutInflater inflater = LayoutInflater.from(mContext);        row = inflater.inflate(mRes, parent, false);        String currentUser = getItem(position);        TextView friendName = (TextView) row.findViewById(R.id.tvFriendName);        String Frndname = currentUser;        friendName.setText(Frndname);        TextView notificationView = (TextView) row.findViewById(R.id.tvNotif);//here i wanted to get the data noOfMsgs        Toast.makeText(mContext, "noOfMsgs:" + numOfMsgs, Toast.LENGTH_LONG).show();            notificationView.setText(noOfMsgs);        return row;    }}
查看完整描述

2 回答

?
烙印99

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊

您只需要更新您在 CustomArrayAdapter 中傳遞的列表對(duì)象,然后通知列表。

適配器.notifyDataSetChanged()

當(dāng)您將列表對(duì)象傳遞給適配器時(shí),列表中的任何更改都將在對(duì)象“數(shù)據(jù)”中自動(dòng)更新。你只需要更新視圖。


查看完整回答
反對(duì) 回復(fù) 2021-09-12
  • 2 回答
  • 0 關(guān)注
  • 195 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)