I know how we inherit methods to methods to get the required output say for example - editText.getText().toString(); in order to get the text from the edit text entered. But I am slightly getting confused at the end of the statement where I pass the preference index along with the getEntries() method.
1) How is the prefIndex value acting with the get entries method to get the correct entry from the list preference?
2) How do we read such java statement?
First you have
listPreference.getEntries() and you can see in the documentation that this returns the list of entries to be shown in the list in subsequent dialogs as an array.
Second you are accessing an specific element in this array using your
prefIndex variable. It would be the same if you had done this:
CharSequence listPreferenceArray = listPreference.getEntries(); listPreferenceArray [prefIndex].doSomething();
I would recommend you to read about manipulating Java Arrays in this documentation so you can understand how this works behind the scenes.