java - disabling edittext android using if else in view holder -
please me in succeeding nightmare regarding on how disable editext using viewholder or way on how using if , else
statement
i have recycler view , lists names , messages. (messenger like). somehow recycler view consists of name ,message , small tag textview “customer closed” if going click recycler view consist of tag “customer closed” not able send messages because closed. otherwise recycler view consist of tag “customer closed” it’s editext set in false.
public void bind(final account account, final firebasechat chat) { itemview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { context context = itemview.getcontext(); if (context instanceof navigationactivity) { final activity activity = (activity) context; final intent intent = new intent(itemview.getcontext(), mychat.class); intent.putextra(chatactivity.key_new, false); intent.putextra(chatactivity.key_account, account); intent.putextra(chatactivity.key_chat, chat); activity.startactivity(intent); } } }); cname.settext(chat.getname()); cname.settypeface(chat.getreadcount() < chat.getnummessages() ? typeface.default_bold : typeface.default); ctextdate.settext(getformatteddate(chat.getlasttime())); ctextmessage.settext(chat.getlastmessage()); ctextmessage.settypeface(chat.getreadcount() < chat.getnummessages() ? typeface.default_bold : typeface.default); } public void bind(final account account, final firebasechatinfo customerinfo) { itemview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { context context = itemview.getcontext(); if (context instanceof navigationactivity) { final activity activity = (activity) context; final intent intent = new intent(itemview.getcontext(), mychat.class); intent.putextra(chatactivity.key_new, false); intent.putextra(chatactivity.key_account, account); intent.putextra(chatactivity.key_chat_info, customerinfo); activity.startactivity(intent); } } }); cname.settext(chatinfo.getname()); cname.settypeface(chatinfo.islastvisitormessaged() ? typeface.default_bold : typeface.default); ctextdate.settext(getformatteddate(chatinfo.getlasttime())); ctextmessage.settext(chatinfo.getlastmessage()); cmessage.settypeface(chatinfo.islastvisitormessaged() ? typeface.default_bold : typeface.default); this.shoptag = (textview) itemview.findviewbyid(r.id.shoptag); shoptag.settext(chatinfo.getshop_id()); this.customerclosed = (textview) itemview.findviewbyid(r.id.customer_closed); this.customerclosed.setvisibility(chatinfo.isclosed() ? view.gone : view.visible); this.message_editext = (edittext)itemview.findviewbyid(r.id.message_editext); message_text.setenabled(!chatinfo.isclosed()); if(customerinfo.isclosed()) { message_text.setenabled(false); }else { message_textt.setenabled(true); } }
i got error
java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.edittext.setenabled(boolean)' on null object reference
all have add else tag
if(customerinfo.isclosed){ message_editext.setenabled(false); } else { message_editext.setenabled(true); }
Comments
Post a Comment