android - How to change the button color of a gridView -
i have gridview displaying buttons content array, change background color of these buttons when clicking/pressed on it. tried onclick , ontouch, go in method, color not background not set. wrong code? please help.
private class imageadapter extends baseadapter { private context mcontext; btnview.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.d("onclick","go"); btnview.setbackgroundcolor(color.rgb(12,11,12)); btnview.setbackgroundcolor(color.parsecolor("#3614b3")); intent data = new intent(); data.setdata(uri.parse("picturestyle" + position)); setresult(result_ok, data); } }); btnview.setontouchlistener(new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { log.d("ontouch","go2"); btnview.setbackgroundcolor(color.parsecolor("#3614b3")); return false; } }); btnview.setontouchlistener(new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub log.d("touch listener",string.valueof(position)); btnview.setbackgroundcolor(0xff00ff00); log.d("touch listener","set"); if ( event.equals(motionevent.action_down) ) { btnview.setbackgroundcolor(0xffff0000); } return false; } });
try v.setbackgroundcolor(color.rgb(12,11,12)); in onclick
Comments
Post a Comment