點選CheckBox核取方塊是否記住密碼

2021-07-23 21:24:18 字數 1341 閱讀 8386

我們在寫登入介面的時候經常會遇見輸入密碼下面有乙個核取方塊記住密碼,但是我個人感覺這個東西看起來簡單,但實現起來還是有一點點小麻煩的,不過我已經操作出來供各位**,下面直接上**:
edittext = (edittext) findviewbyid(r.id.edit_yonghuming);

edittext1 = (edittext) findviewbyid(r.id.ed_mima);

//s例項化這個儲存 ,樣式為私有的

sp = getsharedpreferences(file, mode_private);

//d得到這個editor

editor = sp.edit();

//拿到乙個字串ismemory,用他來判斷有沒有資料,

ismemory = sp.getstring("hh", no);

//判斷有沒有資料,有的話

if (ismemory.equals(yes)) else

//這個時候新增到這個資料庫中

editor.putstring(name, edittext.tostring());

editor.putstring(password, edittext1.tostring());

//並提交儲存

editor.commit();

buttons.setonclicklistener(new view.onclicklistener()

});checkbox1.setonclicklistener(new view.onclicklistener() else

}});

}public void remenber() else

//新增資料覆蓋之前的,放到name 和password中

editor.putstring("name", edittext.gettext().tostring());

editor.putstring("password", edittext1.gettext().tostring());

editor.putstring("hh", yes);

//並提交儲存

editor.commit();

//否則不勾的話

} else if (!checkbox.ischecked())

//新增資料

editor.putstring("hh", no);

//並提交儲存

editor.commit();

}

好了這樣的話就完成了,中間的checkbox1是做了一下是否顯示密碼

checkbox核取方塊樣式

隨著現代瀏覽器的流行,純css設定checkbox也變的很是實用,下面會講到5種與眾不同的checkbox核取方塊。首先,需要新增一段css隱藏所有的checkbox核取方塊,下面我們會改變它的外觀。要做到點需要新增一段 到你的css檔案中。隱藏預設的checkbox input type chec...

MFC中核取方塊 checkbox

來自 http blog.csdn.net dongzhongshu archive 2010 06 30 5705138.aspx checkbox是一種特殊的按鈕 得到核取方塊狀態的函式 cbutton pbtn cbutton getdlgitem idc check int state pb...

jquery操作核取方塊checkbox

jquery判斷checked的三種方法 attr checked 看版本1.6 返回 checked 或 undefined 1.5 返回 true或false prop checked 16 true fals is checked 所有版本 true false,別忘記冒號哦 jquery賦值...