Example usage for android.content.res Resources getStringArray

List of usage examples for android.content.res Resources getStringArray

Introduction

In this page you can find the example usage for android.content.res Resources getStringArray.

Prototype

@NonNull
public String[] getStringArray(@ArrayRes int id) throws NotFoundException 

Source Link

Document

Return the string array associated with a particular resource ID.

Usage

From source file:com.example.georg.theupub.Events.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_events);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  ww w.  j a v a 2  s.c o m

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    list = (ListView) findViewById(R.id.listView);
    Resources res = getResources();
    Titles = res.getStringArray(R.array.EventTitle);
    Descriptions = res.getStringArray(R.array.EventDescription);

    MyAdapter adapter = new MyAdapter(this, Titles, images, Descriptions);
    list.setAdapter(adapter);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showImage(imagesHD[position]);
        }
    });

}

From source file:com.hyzs.onekeyhelp.home.adapter.HomeRightSlideAdapter.java

public HomeRightSlideAdapter(Context context, int[] drawableResource) {
    this.context = context;
    mLayoutInflater = LayoutInflater.from(context);
    Resources res = context.getResources();
    type = res.getStringArray(R.array.right_type);
    this.drawableResource = drawableResource;
}

From source file:com.example.georg.theupub.Offers.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_offers);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w  w  w  .j a  v  a  2s .co  m

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    list = (ListView) findViewById(R.id.listView);
    Resources res = getResources();
    Titles = res.getStringArray(R.array.OfferTitle);
    Descriptions = res.getStringArray(R.array.OfferDescription);

    MyAdapter adapter = new MyAdapter(this, Titles, images, Descriptions);
    list.setAdapter(adapter);

    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showImage(imagesHD[position]);
        }
    });

}

From source file:com.lox.xtendedwallz.Wallpaper.java

private void fetchWallpapers(Resources resources, String packageName, int list) {
    final String[] extras = resources.getStringArray(list);
    for (String extra : extras) {
        int res = resources.getIdentifier(extra, "drawable", packageName);
        if (res != 0) {
            sWallpapers.add(res);//from   ww w . j a v a  2 s.  com
        }
    }
}

From source file:org.totschnig.myexpenses.dialog.VersionDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle bundle = getArguments();//w w  w.  j av  a2  s . co  m
    Activity ctx = (Activity) getActivity();
    LayoutInflater li = LayoutInflater.from(ctx);
    int from = bundle.getInt("from");
    Resources res = getResources();
    int[] versionCodes = res.getIntArray(R.array.version_codes);
    String[] versionNames = res.getStringArray(R.array.version_names);
    final ArrayList<VersionInfo> versions = new ArrayList<VersionInfo>();
    for (int i = 0; i < versionCodes.length; i++) {
        int code = versionCodes[i];
        if (from >= code)
            break;
        int resId = res.getIdentifier("whats_new_" + code, "array", ctx.getPackageName());
        if (resId == 0) {
            Log.e(MyApplication.TAG, "missing change log entry for version " + code);
        } else {
            String changes[] = res
                    .getStringArray(res.getIdentifier("whats_new_" + code, "array", ctx.getPackageName()));
            versions.add(new VersionInfo(code, versionNames[i], changes));
        }
    }
    View view = li.inflate(R.layout.versiondialog, null);
    final ListView lv = (ListView) view.findViewById(R.id.list);
    ArrayAdapter<VersionInfo> adapter = new ArrayAdapter<VersionInfo>(ctx, R.layout.version_row,
            R.id.versionInfoName, versions) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LinearLayout row = (LinearLayout) super.getView(position, convertView, parent);
            VersionInfo version = versions.get(position);
            ((TextView) row.findViewById(R.id.versionInfoName)).setText(version.name);
            ((TextView) row.findViewById(R.id.versionInfoChanges))
                    .setText("- " + TextUtils.join("\n- ", version.changes));
            return row;
        }
    };
    lv.setAdapter(adapter);
    if (MyApplication.getInstance().showImportantUpgradeInfo) {
        view.findViewById(R.id.ImportantUpgradeInfoHeading).setVisibility(View.VISIBLE);
        view.findViewById(R.id.ImportantUpgradeInfoBody).setVisibility(View.VISIBLE);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(ctx)
            .setTitle(getString(R.string.help_heading_whats_new)).setIcon(R.drawable.icon).setView(view)
            .setNegativeButton(android.R.string.ok, this);
    if (!MyApplication.getInstance().isContribEnabled)
        builder.setPositiveButton(R.string.menu_contrib, this);
    return builder.create();
}

From source file:de.baumann.thema.Wallpaper.java

private void fetchWallpapers(Resources resources, String packageName) {
    final String[] extras = resources.getStringArray(R.array.wallpapers);
    for (String extra : extras) {
        int res = resources.getIdentifier(extra, "drawable", packageName);
        if (res != 0) {
            sWallpapers.add(res);/*from ww  w . java2  s  .  co m*/
        }
    }
}

From source file:com.bdevlin.apps.ui.activity.core.HelpActivity.java

private void initFragments() {
    mFragments = new ArrayList<>();
    Resources res = getResources();

    String[] helpTitles = res.getStringArray(R.array.help_screens);

    int[] helpKeys = res.getIntArray(R.array.help_keys);
    int length = helpTitles.length;

    String message = String.format(res.getString(R.string.welcome_messages), "Help", length);
    CharSequence styledText = Html.fromHtml(message);

    if (helpKeys.length != length) {
        if (DEBUG)
            Log.e(TAG, "Mismatch between keys length " + helpKeys.length + " and titles " + length);
        length = Math.min(length, helpKeys.length);
    }/*from   w  w w  .  j av  a2 s . c o  m*/

    for (int i = 0; i < length; i++) {
        HelpListFragment fragment = new HelpListFragment();

        Bundle args = new Bundle();
        int index = helpKeys[i];
        String idKey = "help" + index;
        int contentId = res.getIdentifier(idKey, "string", getPackageName());
        CharSequence content = getText(contentId);
        args.putCharSequence(HelpListFragment.CONTENT, content);
        args.putString(HelpListFragment.TITLE, helpTitles[index]);
        args.putCharSequence(HelpListFragment.MESSAGE, styledText);

        fragment.setArguments(args);
        mFragments.add(fragment);
    }

    // few magic numbers for good luck...
    mQueryIndex = new HashMap<ListQuery, Integer>();

    mQueryIndex.put(ListQuery.inbox, 1);
    mQueryIndex.put(ListQuery.dueToday, 2);
    mQueryIndex.put(ListQuery.dueNextWeek, 2);
    mQueryIndex.put(ListQuery.dueNextMonth, 2);
    mQueryIndex.put(ListQuery.nextTasks, 3);
    mQueryIndex.put(ListQuery.project, 4);
    mQueryIndex.put(ListQuery.context, 5);
    mQueryIndex.put(ListQuery.custom, 6);
    mQueryIndex.put(ListQuery.tickler, 7);
}

From source file:com.github.wkapga.bmicalc.BmicalcActivity.java

public double getperc(double age, double bmi, boolean sex) throws MathException {

    String[] perc;/*from  w  ww. j  a  va  2  s  . c  o  m*/
    Resources res = getResources();
    Double s;
    Double p;

    if (sex == true) {
        perc = res.getStringArray(R.array.boys);
    } else {
        perc = res.getStringArray(R.array.girls);
    }

    int n = perc.length;

    Double[] avalues = new Double[n];
    Double[] lvalues = new Double[n];
    Double[] svalues = new Double[n];
    Double[] pvalues = new Double[n];

    for (int i = 0; i < n; i++) {

        String x1 = (perc[i]).toString();
        String x[] = x1.split(" ");
        avalues[i] = Double.parseDouble(x[0].toString());
        lvalues[i] = Double.parseDouble(x[1].toString());
        svalues[i] = Double.parseDouble(x[2].toString());
        pvalues[i] = Double.parseDouble(x[6].toString());

    }

    age = Math.min(age, (double) 18.0);

    int i = (int) Math.round(age * 2.) - 1; // casting

    s = (Math.pow(bmi / pvalues[i], lvalues[i]) - 1) / (lvalues[i] * svalues[i]);

    // Double sds = ((bmi/m)^l-1) / ( l *s)
    // perzentil = kum.stdnormvert(sds)

    //  double perc = cumulativeProbability(double -2,02);
    p = new NormalDistributionImpl(0, 1).cumulativeProbability(s, 20);
    p = p * 100;
    return p;
}

From source file:net.named_data.nfd.FaceStatusFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (m_faceStatusAdapter == null) {
        m_listItems = new ArrayList<>();

        Resources res = getResources();
        m_scopes = res.getStringArray(R.array.face_scopes);
        m_linkTypes = res.getStringArray(R.array.face_link_types);
        m_persistencies = res.getStringArray(R.array.face_persistency);

        // Get face status information
        FaceStatus faceStatus = new FaceStatus();
        try {/*from w ww.j  a  va  2s  . c  o  m*/
            byte[] args = getArguments().getByteArray(EXTRA_FACE_INFORMATION);
            faceStatus.wireDecode(new Blob(args).buf());
        } catch (EncodingException e) {
            G.Log("EXTRA_FACE_INFORMATION: EncodingException: " + e);
        }

        // Creating list of items to be displayed
        m_listItems.add(new ListItem(R.string.face_id, String.valueOf(faceStatus.getFaceId())));
        m_listItems.add(new ListItem(R.string.local_face_uri, faceStatus.getLocalUri()));
        m_listItems.add(new ListItem(R.string.remote_face_uri, faceStatus.getRemoteUri()));
        m_listItems.add(new ListItem(R.string.expires_in,
                faceStatus.getExpirationPeriod() < 0 ? getString(R.string.expire_never)
                        : PeriodFormat.getDefault().print(new Period(faceStatus.getExpirationPeriod()))));
        m_listItems.add(new ListItem(R.string.face_scope, getScope(faceStatus.getFaceScope())));
        m_listItems
                .add(new ListItem(R.string.face_persistency, getPersistency(faceStatus.getFacePersistency())));
        m_listItems.add(new ListItem(R.string.link_type, getLinkType(faceStatus.getLinkType())));
        m_listItems.add(new ListItem(R.string.in_interests, String.valueOf(faceStatus.getNInInterests())));
        m_listItems.add(new ListItem(R.string.in_data, String.valueOf(faceStatus.getNInDatas())));
        m_listItems.add(new ListItem(R.string.out_interests, String.valueOf(faceStatus.getNOutInterests())));
        m_listItems.add(new ListItem(R.string.out_data, String.valueOf(faceStatus.getNOutDatas())));
        m_listItems.add(new ListItem(R.string.in_bytes, String.valueOf(faceStatus.getNInBytes())));
        m_listItems.add(new ListItem(R.string.out_bytes, String.valueOf(faceStatus.getNOutBytes())));

        m_faceStatusAdapter = new FaceStatusAdapter(getActivity(), m_listItems);
    }
    // setListAdapter must be called after addHeaderView.  Otherwise, there is an exception on some platforms.
    // http://stackoverflow.com/a/8141537/2150331
    setListAdapter(m_faceStatusAdapter);
}

From source file:com.jbirdvegas.mgerrit.GerritSwitcher.java

private void initialiseGerritList(Resources res) {
    final ArrayList<String> teams = new ArrayList<>();
    Collections.addAll(teams, res.getStringArray(R.array.gerrit_names));

    final ArrayList<String> urls = new ArrayList<>();
    Collections.addAll(urls, res.getStringArray(R.array.gerrit_webaddresses));

    GerritTeamsHelper teamsHelper = new GerritTeamsHelper();
    teams.addAll(teamsHelper.getGerritNamesList());
    urls.addAll(teamsHelper.getGerritUrlsList());

    Set<GerritDetails> gerrits = new HashSet<>();

    int min = Math.min(teams.size(), urls.size());
    for (int i = 0; i < min; i++) {
        gerrits.add(new GerritDetails(teams.get(i), urls.get(i)));
    }// w  w  w. j  av a  2  s.  c  o  m
    gerritData = new ArrayList<>(gerrits);
    Collections.sort(gerritData);
}