Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieve values from array.xml and check it in main activity
    primarykey
    data
    text
    <p>I have no clear working knowledge of retrieving values from an XML file and how to use it effectively. Can some one help me understand,how to do it?</p> <p>Here my file and in my main activity.what i need to do, is-i will select an operator from settings then I will check for the exact operator name and will retrieve couple of desired strings from a class named CallManager and will call by another code segmentation. i did it for a single operator where preString and internal digit size was fixed.So it was no problem.But i need to do for couple of them,-taking name from preferences.please help.thanks-Piyal</p> <pre><code>&lt;string-array name="operatormodes"&gt; &lt;item &gt;Airtel&lt;/item&gt; &lt;item &gt;Banglalink&lt;/item&gt; &lt;item &gt;Grameen Phone&lt;/item&gt; &lt;item &gt;Robi&lt;/item&gt; &lt;item &gt;TeleTalk&lt;/item&gt; &lt;/string-array&gt; prefs = PreferenceManager.getDefaultSharedPreferences(this); // Operator prefs.edit().putString(PreferencesActivity.KEY_OPERATOR_MODE, CaptureActivity.DEFAULT_OPERATOR_MODE).commit(); // Retrieve from preferences, and set in this Activity, the Operator mode String[] operatorModes = getResources().getStringArray(R.array.operatormodes); String operatorModeName = prefs.getString(PreferencesActivity.KEY_OPERATOR_MODE, operatorModes[0]); Log.w("im changed", "Airtel"); if (operatorModeName.equals(operatorModes[0])) { callManager.setOperatorName("Airtel"); callManager.setOperatorBasedInternalDigit("Airtel"); callManager.setOperatorBasedInternalPreString("Airtel"); callManager.setPreString(callManager.internalPreString); } else if (operatorModeName.equals(operatorModes[1])) { callManager.setOperatorName("Banglalink"); callManager.setOperatorBasedInternalDigit("Banglalink"); callManager.setOperatorBasedInternalPreString("Banglalink"); callManager.setPreString(callManager.internalPreString); } else if (operatorModeName.equals(operatorModes[2])) { callManager.setOperatorName("Grameen Phone"); callManager.setOperatorBasedInternalDigit("Grameen Phone"); callManager.setOperatorBasedInternalPreString("Grameen Phone"); callManager.setPreString(callManager.internalPreString); } else if (operatorModeName.equals(operatorModes[3])) { callManager.setOperatorName("Robi"); callManager.setOperatorBasedInternalDigit("Robi"); callManager.setOperatorBasedInternalPreString("Robi"); callManager.setPreString(callManager.internalPreString); } else if (operatorModeName.equals(operatorModes[4])) { callManager.setOperatorName("TeleTalk"); callManager.setOperatorBasedInternalDigit("TeleTalk"); callManager.setOperatorBasedInternalPreString("TeleTalk"); callManager.setPreString(callManager.internalPreString); } prefs.registerOnSharedPreferenceChangeListener(listener); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload