Android Access toggle button status from a custom view -
i have activity select_episode
. creates adapter of customlistviewadapter
contains toggle button.
in customlistviewadapter
, can check status of toggle button in getview()
method.
final togglebutton tgb1 = (togglebutton) vi.findviewbyid(r.id.togglebutton1); tgb1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(tgb1.ischecked()){ //do }else{ //do } } });
now rather using setonclicklistener
on customlistviewadapter
want use or check status of toggle button activity. in case activity select_episode
how can done?
complete code of select_episode
: http://pastebin.com/r1msrrqj complete code of customlistviewadapter
: http://pastebin.com/u8zqw924
implementing listeners in activity may not idea. suggest implement these in getview()
method in customlistviewadapter
class.
then in onclick
method can save togglebutton
value sharedpreferences
(with special key, identify togglebutton
specified listview
position) or try write method pass list
values of togglebuttons
activity
.
Comments
Post a Comment