亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

內容復用問題

為什么我在bean中添加了isChecked,按照你寫的方法寫了一遍,還是出現復用呀,第二種方法不會有復用,這是怎么回事呀

正在回答

3 回答

在MainActivity中用cb.setChecked(bean.isChecked());
為何出錯?

0 回復 有任何疑惑可以回復我~

package com.doop.commonadapter.bean;

/**
?* Created by king on 2016/12/4.
?*/

public class Bean {
??? //定義變量
??? private String title;
??? private String desc;
??? private String time;
??? private String phone;
??? private Boolean isChecked;

??? //記錄復選框是否選中


??? public Boolean getChecked() {
??????? return isChecked;
??? }

??? public void setChecked(Boolean checked) {
??????? isChecked = checked;
??? }

??? //添加構造方法
??? //代碼→生成→構造函數
??? public Bean() {
??? }


??? //添加屬性構造方法
??? //代碼→生成→構造函數(按住shift全選參數)
??? public Bean(String title, String desc, String time, String phone) {
??????? this.title = title;
??????? this.desc = desc;
??????? this.time = time;
??????? this.phone = phone;
??? }

??? // 生成get和set
//代碼→生成→構造get和set(按住shift全選參數)

??? public String getTitle() {
??????? return title;
??? }

??? public Bean setTitle(String title) {
??????? this.title = title;
??????? return this;
??? }

??? public String getDesc() {
??????? return desc;
??? }

??? public Bean setDesc(String desc) {
??????? this.desc = desc;
??????? return this;
??? }

??? public String getTime() {
??????? return time;
??? }

??? public Bean setTime(String time) {
??????? this.time = time;
??????? return this;
??? }

??? public String getPhone() {
??????? return phone;
??? }

??? public Bean setPhone(String phone) {
??????? this.phone = phone;
??????? return this;
??? }
}

0 回復 有任何疑惑可以回復我~

貼個代碼吧,仔細檢查可能漏寫了什么

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android-打造萬能適配器
  • 參與學習       34696    人
  • 解答問題       116    個

本課程通過對傳統的ListView數據綁定寫法,打造萬能適配器

進入課程

內容復用問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號