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:at.univie.sensorium.SensorService.java

private void startSensors() {
    Resources res = getResources();
    String[] sensorclassnames = res.getStringArray(R.array.sensors);

    for (String classname : sensorclassnames) {
        Log.d("SENSORS", classname);
        try {// ww w .  j a va 2 s. co  m
            AbstractSensor s = (AbstractSensor) Class.forName(classname).newInstance();
            SensorRegistry.getInstance().registerSensor(s);
        } catch (ClassNotFoundException e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            Log.d(SensorRegistry.TAG, sw.toString());
        } catch (InstantiationException e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            Log.d(SensorRegistry.TAG, sw.toString());
        } catch (IllegalAccessException e) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            Log.d(SensorRegistry.TAG, sw.toString());
        }
    }
}

From source file:de.sourcestream.movieDB.adapter.TVSlideAdapter.java

public TVSlideAdapter(FragmentManager fm, Resources res) {
    super(fm);/*from  w w  w  . j a  v  a  2s .  c om*/
    this.manager = fm;
    navMenuTitles = res.getStringArray(R.array.tvTabs);
    this.res = res;
}

From source file:de.sourcestream.movieDB.adapter.MovieSlideAdapter.java

public MovieSlideAdapter(FragmentManager fm, Resources res) {
    super(fm);/*  www  .j a  va2 s .c o m*/
    this.manager = fm;
    navMenuTitles = res.getStringArray(R.array.moviesTabs);
    this.res = res;
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_the_menu);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from w  w w  .  ja va 2 s .com*/

    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.MenuTitle);
    Descriptions = res.getStringArray(R.array.MenuDescription);

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

From source file:com.jimsuplee.femaleastronauts.FemaleAstronautsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    //photoMap.put("ACAZ C.2 2 seat fighter",R.drawable.belgium);
    //Shannon_Walker
    //Dorothy_Marie_Dottie_Metcalf_Lindenburger

    super.onCreate(savedInstanceState);
    Context ctx = getApplicationContext();
    setContentView(R.layout.activity_female_astronauts);
    Resources res = ctx.getResources();
    String[] options = res.getStringArray(R.array.astronauts);
    TypedArray icons = res.obtainTypedArray(R.array.astronaut_icons);
    setListAdapter(new ImageAndTextAdapter(ctx, R.layout.main_list_item, options, icons));
    ListView listView = getListView();
    listView.setTextFilterEnabled(true);
    listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //Intent i = new Intent("");
            Intent iAstronaut = new Intent("com.jimsuplee.femaleastronauts.Astronaut");
            //NO/* w  w  w. j a v  a  2s .c o m*/
            //Intent iAstronaut = new Intent("Astronaut");
            //NO:This item is not a TextView but is a LinearLayout
            //String astronautChoice = ((TextView) view).getText().toString();
            LinearLayout ll = (LinearLayout) view;
            TextView tv = (TextView) ll.findViewById(R.id.option_text);
            String astronautChoice = tv.getText().toString();
            iAstronaut.putExtra("astronautChoice", astronautChoice);
            //startActivityForResult(iAstronaut, 0);
            //Log.w(TAG, "In Astronaut, about to startActivity(iAstronaut)");
            startActivity(iAstronaut);
            //i.setData(Uri.parse(astronautChoice));
            //setResult(RESULT_OK, i);
            //finish();

        }
    });
}

From source file:de.stkl.gbgvertretungsplan.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*/*from   w w w  .  j  a v a 2s.c om*/
            mSpinnerList = new ArrayList<String>();
            mSpinnerList.add(getString(R.string.action_spinner_mainview_today));
            mSpinnerList.add(getString(R.string.action_spinner_mainview_tomorrow));
            mSpinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, mSpinnerList);
    */

    View rootView = inflater.inflate(R.layout.fragment_about, container, false).getRootView();

    final Resources res = getResources();
    String[] titles = res.getStringArray(R.array.about_item_titles);
    String[] summaries = res.getStringArray(R.array.about_item_summaries);

    if (titles.length == summaries.length) {
        for (int i = 0; i < titles.length; i++) {
            // format string
            switch (i) {
            // copyright and app information
            case 0:
                try {
                    titles[i] = String.format(titles[i], getString(R.string.app_name), getActivity()
                            .getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }
                break;
            }

            View aboutItem = inflater.inflate(R.layout.item_about, (ViewGroup) rootView, false);
            ((TextView) aboutItem.findViewById(R.id.title)).setText(titles[i]);
            if (!summaries[i].equals(""))
                ((TextView) aboutItem.findViewById(R.id.summary)).setText(summaries[i]);
            else {
                View v = aboutItem.findViewById(R.id.summary);
                ((ViewGroup) v.getParent()).removeView(v);
            }

            // assign onclick handler
            switch (i) {
            // terms of use
            case 1:
                aboutItem.findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        DialogFragment newFragment = null;
                        newFragment = new PopupDialog(
                                Util.convertStreamToString(res.openRawResource(R.raw.tos)));
                        newFragment.show(getActivity().getSupportFragmentManager(), "tos");
                    }
                });
                break;
            // open source licenses
            case 2:
                aboutItem.findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        DialogFragment newFragment = null;
                        newFragment = new PopupDialog(
                                Util.convertStreamToString(res.openRawResource(R.raw.licenses)));
                        newFragment.show(getActivity().getSupportFragmentManager(), "license");
                    }
                });
                break;
            }

            ((ViewGroup) rootView).addView(aboutItem);
        }
    }
    return rootView;
}

From source file:org.cowboycoders.cyclisimo.TurboTrainerListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.generic_list_select);

    mHandler = new Handler();

    sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);

    listView = (ListView) findViewById(R.id.generic_list);

    this.setTitle(this.getString(R.string.turbotrainer_select_title));

    LinearLayout bottomButtons = (LinearLayout) this.findViewById(R.id.generic_list_buttons_container);
    bottomButtons.setVisibility(View.GONE);

    Resources res = getResources();
    String[] trainers = res.getStringArray(R.array.turbotrainer_opions);

    resourceCursorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trainers);

    listView.setAdapter(resourceCursorAdapter);

}

From source file:org.cowboycoders.cyclismo.TurboTrainerListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.generic_list_select);

    mHandler = new Handler();

    sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE);

    listView = (ListView) findViewById(R.id.generic_list);

    this.setTitle(this.getString(R.string.turbotrainer_select_title));

    LinearLayout bottomButtons = (LinearLayout) this.findViewById(R.id.generic_list_buttons_container);
    bottomButtons.setVisibility(View.GONE);

    Resources res = getResources();
    String[] trainers = res.getStringArray(R.array.turbotrainer_options);

    resourceCursorAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, trainers);

    listView.setAdapter(resourceCursorAdapter);

}

From source file:tw.com.geminihsu.app01.fragment.Fragment_NotifyList.java

private void findViews() {
    listView = (ListView) getView().findViewById(R.id.listView1);

    listView.setVisibility(View.VISIBLE);

    Resources res = getResources();
    String[] menu = res.getStringArray(R.array.myaccount);
    final ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < menu.length; ++i) {
        list.add(menu[i]);/*from  ww  w  .j  ava2s  .  c  o  m*/
    }

}

From source file:org.lispmob.noroot.IPC.java

public void run() {
    int len = 0;//w  w  w . j  a v  a2  s  .  co m
    ByteBuffer buf = ByteBuffer.allocate(9000);
    while (!ipc_thread.isInterrupted()) {
        buf.clear();
        try {
            len = ipc_channel.read(buf);
            if (len == 0) {
                continue;
            }
            buf.flip();
            String json_str = EncodingUtils.getString(buf.array(), "utf8");
            JSONObject jObj = new JSONObject(json_str);
            int ipc_type = jObj.getInt("type");
            System.out.println("LISPmob: Received IPC message: " + ipc_type);
            switch (ipc_type) {
            case IPC_LOG_MSG:
                LISPmobVPNService.err_msg_code = jObj.getInt("err_msg_code");
                Thread.sleep(1000);
                if (LISPmobVPNService.err_msg_code != 0) {
                    /* If LISPmob is not the active windows, the error msg code is not clean
                     * and we send a notification of the error */
                    Resources res = vpn_service.getResources();
                    String[] err_msg = res.getStringArray(R.array.ErrMsgArray);
                    String msg = err_msg[LISPmobVPNService.err_msg_code];
                    //notifications.notify_msg( msg);
                }
                break;
            case IPC_PROTECT_SOCKS:
                int socket = jObj.getInt("socket");
                if (socket != -1) {
                    boolean sock_protect = false;
                    int retry = 0;
                    while (!sock_protect && retry < 30) {
                        if (!vpn_service.protect(socket)) {
                            retry++;
                            Thread.sleep(200);
                        } else {
                            sock_protect = true;
                            System.out.println(
                                    "LISPmob: The socket " + socket + " has been protected (VPN Service)");
                        }
                    }
                }
                break;
            default:
                System.out.println("***** Unknown IPC message: " + ipc_type);
                break;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}