NexusDialog
NexusDialog copied to clipboard
Allow form elements visibility
I've added the ability to hide elements and sections.
Thanks for your contribution!
I'm reviewing the code changes, but would you please squash the commits into one? I'll add my comments once that's done. Thanks.
@Rodolfocartas any update on your branch?
When this PR will be merged? Thanks.
@dneykov: It hasn't been merged yet because I haven't received an update from @Rodolfocartas regarding my comments. In any case, it's likely that this PR is out-of-sync with master, so it might have to be re-implemented.
If you need this functionality, one way to get it is to do it on the View object directly. Each FormElement provides access to the its underlying view.
Thanks for your quick response. I will take your suggestions.
@dkharrat When I try to access the view is giving an error:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.github.dkharrat.nexusdialog.FormModel.getValue(java.lang.String)' on a null object reference
Here is what I'm trying:
tmpElement = new EditTextController(this, field.getId(), field.getLabel(), "", field.isRequired());
if(field.isHidden()) {
tmpElement.getView().setVisibility(View.INVISIBLE);
}
return tmpElement;
Thanks
@dneykov you're getting this crash due to the view not being completely initialized yet. They are initialized once the FormActivity's onCreate method is done. After that, you should be able to access the view of any fields. Something like this should work:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFormController().getElement(fieldId).getView().setVisibility(View.GONE);
}
Hope this helps. I think it would be useful to get this hide/show functionality builtin to the library. I'll look into implementing it soon.