List of usage examples for android.content.res Resources getStringArray
@NonNull public String[] getStringArray(@ArrayRes int id) throws NotFoundException
From source file:hku.fyp14017.blencode.ui.fragment.UserBrickDataEditorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragmentView = inflater.inflate(hku.fyp14017.blencode.R.layout.fragment_brick_data_editor, container, false);//from w ww. j a va2 s.c o m fragmentView.setFocusableInTouchMode(true); fragmentView.requestFocus(); context = getActivity(); brickView = View.inflate(context, hku.fyp14017.blencode.R.layout.brick_user_editable, null); updateBrickView(); editorBrickSpace = (LinearLayout) fragmentView .findViewById(hku.fyp14017.blencode.R.id.brick_data_editor_brick_space); editorBrickSpace.addView(brickView); ListView buttonList = (ListView) fragmentView.findViewById(hku.fyp14017.blencode.R.id.button_list); buttonList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Resources resources = getResources(); String[] actions = resources.getStringArray(hku.fyp14017.blencode.R.array.data_editor_buttons); String action = actions[position]; if (action.equals(resources.getString(hku.fyp14017.blencode.R.string.add_text))) { addTextDialog(); } if (action.equals(resources.getString(hku.fyp14017.blencode.R.string.add_variable))) { addVariableDialog(); } if (action.equals(resources.getString(hku.fyp14017.blencode.R.string.add_line_break))) { addLineBreak(); } if (action.equals(resources.getString(hku.fyp14017.blencode.R.string.close))) { onUserDismiss(); } } }); return fragmentView; }
From source file:com.crystal.CrystalBeanWallpapers.Wallpaper.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mContext = this; // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() { public void onPageSelected(int position) { mCurrentFragment = position; // Check if item is customizable mCustomizable = (mCurrentFragment == 0); Wallpaper.this.invalidateOptionsMenu(); }//from w ww .j a va2 s . c o m }); mWallpapers.clear(); final Resources resources = getResources(); final String packageName = getPackageName(); fetchWallpapers(resources, packageName, R.array.wallpapers); mWallpaperInfo = resources.getStringArray(R.array.info); mWallpaperManager = WallpaperManager.getInstance(mContext); }
From source file:org.getlantern.firetweet.preference.ValueDependencyCheckBoxPreference.java
public ValueDependencyCheckBoxPreference(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final Resources res = context.getResources(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle, 0);/*from w ww . java2 s . c o m*/ mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey); final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0); mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null; mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault); a.recycle(); }
From source file:org.getlantern.firetweet.preference.ValueDependencyDialogPreference.java
public ValueDependencyDialogPreference(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final Resources res = context.getResources(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle, 0);/*ww w. j a v a 2 s .c o m*/ mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey); final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0); mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null; mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault); a.recycle(); }
From source file:org.getlantern.firetweet.preference.ValueDependencySeekBarDialogPreference.java
public ValueDependencySeekBarDialogPreference(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final Resources res = context.getResources(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle, 0);//from ww w . j a v a2 s. c om mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey); final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0); mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null; mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault); a.recycle(); }
From source file:com.paranoid.ParanoidWallpapers.Wallpaper.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mContext = this; // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() { public void onPageSelected(int position) { mCurrentFragment = position; // Check if item is customizable mCustomizable = (mCurrentFragment == 0); try { Method method = Wallpaper.class.getMethod("invalidateOptionsMenu", new Class[] {}); method.invoke(Wallpaper.this); } catch (Exception e) { }/*from www . jav a2 s . com*/ } }); mWallpapers.clear(); final Resources resources = getResources(); final String packageName = getPackageName(); fetchWallpapers(resources, packageName, R.array.wallpapers); mWallpaperInfo = resources.getStringArray(R.array.info); mWallpaperManager = WallpaperManager.getInstance(mContext); mSectionsPagerAdapter.notifyDataSetChanged(); }
From source file:org.zakky.memopad.PadActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCanvases = new CanvasFragment[2]; for (int i = 0; i < mCanvases.length; i++) { mCanvases[i] = new CanvasFragment(); }/* ww w .j a va2 s . co m*/ fixOrientation(); setContentView(R.layout.placeholder); final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction tx = fm.beginTransaction(); try { final Fragment old = fm.findFragmentByTag(FG_TAG_CANVAS); if (old != null) { tx.remove(old); } tx.add(R.id.container, getCurrentCanvas(), FG_TAG_CANVAS); } finally { tx.commit(); } if (MyDialogFragment.showAtStartup(this)) { new MyDialogFragment().show(fm.beginTransaction(), "dialog"); } final Resources resources = getResources(); /* * ? */ mPenColorValues = resources.getIntArray(R.array.pen_color_value_list); /* * */ mBgColorLabels = resources.getStringArray(R.array.bg_color_label_list); mBgColorValues = resources.getIntArray(R.array.bg_color_value_list); }
From source file:com.todoroo.astrid.sync.SyncProviderPreferences.java
/** * * @param resource/* ww w .j ava 2 s . c om*/ * if null, updates all resources */ @Override public void updatePreferences(Preference preference, Object value) { final Resources r = getResources(); // interval if (r.getString(getUtilities().getSyncIntervalKey()).equals(preference.getKey())) { int index = AndroidUtilities.indexOf(r.getStringArray(R.array.sync_SPr_interval_values), (String) value); if (index <= 0) preference.setSummary(R.string.sync_SPr_interval_desc_disabled); else preference.setSummary(r.getString(R.string.sync_SPr_interval_desc, r.getStringArray(R.array.sync_SPr_interval_entries)[index])); } // status else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); String status; //String subtitle = ""; //$NON-NLS-1$ // ! logged in - display message, click -> sync if (!loggedIn) { status = r.getString(R.string.sync_status_loggedout); statusColor = Color.rgb(19, 132, 165); } // sync is occurring else if (getUtilities().isOngoing()) { status = r.getString(R.string.sync_status_ongoing); statusColor = Color.rgb(0, 0, 100); } // last sync had errors else if (getUtilities().getLastError() != null || getUtilities().getLastAttemptedSyncDate() != 0) { // last sync was failure if (getUtilities().getLastAttemptedSyncDate() != 0) { status = r.getString(R.string.sync_status_failed, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastAttemptedSyncDate()))); statusColor = Color.rgb(100, 0, 0); if (getUtilities().getLastSyncDate() > 0) { // subtitle = r.getString(R.string.sync_status_failed_subtitle, // DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, // new Date(getUtilities().getLastSyncDate()))); } } else { long lastSyncDate = getUtilities().getLastSyncDate(); String dateString = lastSyncDate > 0 ? DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, new Date(lastSyncDate)) : ""; //$NON-NLS-1$ status = r.getString(R.string.sync_status_errors, dateString); statusColor = Color.rgb(100, 100, 0); } } else if (getUtilities().getLastSyncDate() > 0) { status = r.getString(R.string.sync_status_success, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastSyncDate()))); statusColor = Color.rgb(0, 100, 0); } else { status = r.getString(R.string.sync_status_never); statusColor = Color.rgb(0, 0, 100); } preference.setTitle(R.string.sync_SPr_sync); preference.setSummary(r.getString(R.string.sync_SPr_status_subtitle, status)); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { startSync(); return true; } }); View view = findViewById(R.id.status); if (view != null) view.setBackgroundColor(statusColor); } else if (r.getString(R.string.sync_SPr_key_last_error).equals(preference.getKey())) { if (getUtilities().getLastError() != null) { // Display error final String service = getTitle().toString(); final String lastErrorFull = getUtilities().getLastError(); final String lastErrorDisplay = adjustErrorForDisplay(r, lastErrorFull, service); preference.setTitle(R.string.sync_SPr_last_error); preference.setSummary(R.string.sync_SPr_last_error_subtitle); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @SuppressWarnings("nls") public boolean onPreferenceClick(Preference pref) { // Show last error new AlertDialog.Builder(SyncProviderPreferences.this).setTitle(R.string.sync_SPr_last_error) .setMessage(lastErrorDisplay) .setPositiveButton(R.string.sync_SPr_send_report, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text") .putExtra(Intent.EXTRA_EMAIL, new String[] { "android-bugs@astrid.com" }) .putExtra(Intent.EXTRA_SUBJECT, service + " Sync Error") .putExtra(Intent.EXTRA_TEXT, lastErrorFull); startActivity(Intent.createChooser(emailIntent, r.getString(R.string.sync_SPr_send_report))); } }).setNegativeButton(R.string.DLG_close, null).create().show(); return true; } }); } else { PreferenceCategory statusCategory = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_group_status)); statusCategory.removePreference(findPreference(r.getString(R.string.sync_SPr_key_last_error))); } } // log out button else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { DialogUtilities.okCancelDialog(SyncProviderPreferences.this, r.getString(R.string.sync_forget_confirm), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { logOut(); initializePreference(getPreferenceScreen()); } }, null); return true; } }); if (!loggedIn) { PreferenceCategory category = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_key_options)); category.removePreference(preference); } } }
From source file:pt.ubi.di.pdm.swipe.MainActivity.java
private String[][] getExampleTexts() { Resources res = getResources(); TypedArray ta = res.obtainTypedArray(R.array.text_examples); int n = ta.length(); String[][] array = new String[n][]; for (int i = 0; i < n; ++i) { int id = ta.getResourceId(i, 0); if (id > 0) { array[i] = res.getStringArray(id); WriteBtn(this, array[i][0].toString(), array[i][1].toString()); Log.i("ARRAY", String.valueOf(array[i][0].toString() + "---->" + array[i][1].toString())); } else {//from w w w . ja v a 2 s . c o m Log.e("GET EXAMPLES", "ESTA ALGO DE ERRADO COM O XAML"); } } ta.recycle(); // Important! return array; }
From source file:com.doplgangr.secrecy.settings.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); this.context = getActivity(); Resources res = getResources(); stealth_mode_message = getString(R.string.Settings__stealth_mode_message); creditsNames = res.getStringArray(R.array.Credits__names); creditsDescription = res.getStringArray(R.array.Credits__description); creditsLinks = res.getStringArray(R.array.Credits__links); contributorNames = res.getStringArray(R.array.Contributor__names); contributorDescription = res.getStringArray(R.array.Contributor__description); contributorLinks = res.getStringArray(R.array.Contributor__links); libraries = getString(R.string.Settings__libraries_message); preparePreferenceStealthMode();/*www.j a v a 2 s . com*/ preparePreferenceStealthModePassword(); preparePreferenceMaxImageSize(); preparePreferenceVaultRoot(); preparePreferenceVaultMove(); preparePreferenceCreditList(); preparePreferenceTranslatorsList(); preparePreferenceVersion(); preparePreferenceLegal(); }