課程
/移動(dòng)開發(fā)
/Android
/Android-打造萬(wàn)能適配器
為什么我在bean中添加了isChecked,按照你寫的方法寫了一遍,還是出現(xiàn)復(fù)用呀,第二種方法不會(huì)有復(fù)用,這是怎么回事呀
2015-08-06
源自:Android-打造萬(wàn)能適配器 5-2
正在回答
在MainActivity中用cb.setChecked(bean.isChecked());為何出錯(cuò)?
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;
??? //記錄復(fù)選框是否選中
??? public Boolean getChecked() {??????? return isChecked;??? }
??? public void setChecked(Boolean checked) {??????? isChecked = checked;??? }
??? //添加構(gòu)造方法??? //代碼→生成→構(gòu)造函數(shù)??? public Bean() {??? }
??? //添加屬性構(gòu)造方法??? //代碼→生成→構(gòu)造函數(shù)(按住shift全選參數(shù))??? public Bean(String title, String desc, String time, String phone) {??????? this.title = title;??????? this.desc = desc;??????? this.time = time;??????? this.phone = phone;??? }
??? // 生成get和set//代碼→生成→構(gòu)造get和set(按住shift全選參數(shù))
??? 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;??? }}
貼個(gè)代碼吧,仔細(xì)檢查可能漏寫了什么
舉報(bào)
本課程通過(guò)對(duì)傳統(tǒng)的ListView數(shù)據(jù)綁定寫法,打造萬(wàn)能適配器
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-12-05
在MainActivity中用cb.setChecked(bean.isChecked());
為何出錯(cuò)?
2016-12-05
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;
??? //記錄復(fù)選框是否選中
??? public Boolean getChecked() {
??????? return isChecked;
??? }
??? public void setChecked(Boolean checked) {
??????? isChecked = checked;
??? }
??? //添加構(gòu)造方法
??? //代碼→生成→構(gòu)造函數(shù)
??? public Bean() {
??? }
??? //添加屬性構(gòu)造方法
??? //代碼→生成→構(gòu)造函數(shù)(按住shift全選參數(shù))
??? public Bean(String title, String desc, String time, String phone) {
??????? this.title = title;
??????? this.desc = desc;
??????? this.time = time;
??????? this.phone = phone;
??? }
??? // 生成get和set
//代碼→生成→構(gòu)造get和set(按住shift全選參數(shù))
??? 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;
??? }
}
2015-12-08
貼個(gè)代碼吧,仔細(xì)檢查可能漏寫了什么