Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OnPreferenceClickListener: what does the boolean return value do?

From this example:

private static Preference.OnPreferenceClickListener BindToPreferenceClickListener = new Preference.OnPreferenceClickListener() {
    public boolean onPreferenceClick(Preference preference) {
        boolean isHandled = false;
        if (...) {
           isHandled = true;
        }
        return isHandled;
    }
}

What does the return value of 'true' do? The API documentation states that the value indicates that the click was handled if 'true', but what does that really mean? I thought it meant that the editor for the passed preference was not called and a custom editor could be used instead, but my experimentation concludes that the default editor is called in either state.

like image 613
vedavis Avatar asked Jan 08 '13 12:01

vedavis


People also ask

How to return a boolean value from a Boolean expression?

However, it is more common to return boolean values from boolean expressions, for conditional testing (see below). A Boolean expression is a Java expression that returns a Boolean value: true or false. You can use a comparison operator, such as the greater than ( >) operator to find out if an expression (or a variable) is true:

How to execute code based on the Boolean answer of function?

You can execute code based on the Boolean answer of a function: Example Print "YES!" if the function returns True, otherwise print "NO!": def myFunction() : return True if myFunction(): print("YES!") else: print("NO!") Try it Yourself »

What is the difference between Boolean and Boolean expression in Java?

A boolean type is declared with the boolean keyword and can only take the values true or false: However, it is more common to return boolean values from boolean expressions, for conditional testing (see below). A Boolean expression is a Java expression that returns a Boolean value: true or false.

What is Boolean indexing?

Boolean indexing is a type of indexing which uses actual values of the data in the DataFrame. In boolean indexing, we can filter a data in four ways – In order to access a dataframe with a boolean index, we have to create a dataframe in which index of dataframe contains a boolean value that is “True” or “False”.


1 Answers

As the OnPreferenceChangeListener.onPreferenceChange method documentation says:

Returns True to update the state of the Preference with the new value.

The method is run before persisting the new value to the preferences. If you return false, the value is not persisted. If you return true, it is persisted.

like image 174
Diana Avatar answered Sep 30 '22 02:09

Diana