Android: how to get dirty (changed) properties

How to get dirty (modified) properties (any subclasses of controls) among multiple properties on a layout. Does android have a dirty flag to mark if the layout has any content-modified field?

Actually I have a layout which has several edittexts, spinners, datewidgets. Now executing the save should make a request to the server only if the user has changed anything. I wanted to know how I can check if the user has changed something in this layout or not. Does Android have any flag or something that gets set when the user modifies any input control?

Hmm..Blckberry I have a Dirty () {boolean net.rim.device.api.ui.Manager.isDirty ()} method.

+2


a source to share


3 answers


The activity is not closely related to the elements of your layout, so you have to do it yourself. You can save a map where the key is the ID of the layout element and the value is boolean that signals whether the element has been modified by the user. You will probably need to set up listeners for each element (e.g. OnKeyListener for your EditTexts) and additionally write their initial values.



+4


a source


Does android have a dirty flag? if there is a field in the layout that has changed content



No, sorry.

0


a source


A bit late with my answer, but the way I do it is to store the form (activity) fields in a container object (for validation, etc.). This container object implements the java.lang.Comparable interface, where T is the same class as the container.

Then compareTo (T) method returns

  • 0 if both objects are equal (thus the shape of the content has not changed).
  • -1 indicates that something has changed and hence the data is dirty.

You can always return other numeric values ​​to indicate what exactly changed, if required.

0


a source







All Articles