listDataHeader for a String

0

I would like to know if it is possible to return my listDataHeader to a string, because in my system.out it returns the value, but I do not know how to pass it to a string ...

  private void prepareListData() {
    //
    //   final Intent intent = getIntent();
    // String result = (String) intent.getSerializableExtra("result");

    //  listDataHeader = new ArrayList<String>();
    listDataChild = new HashMap<String, List<String>>();


    // Adding headers
    Resources res = getResources();
    String[] headers = res.getStringArray(R.array.nav_drawer_labels);
    listDataHeader = Arrays.asList(headers);



    Button btnaddlivro = (Button) findViewById(R.id.btnaddlivro);
    btnaddlivro.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity2.this, Activity_addinf.class);
            intent.putExtra("mId", id);
            startActivity(intent);
        }

    });


    List<String> home, friends, notifs;
    String[] shome, sfriends, snotifs;

    shome = res.getStringArray(R.array.Informatica);
    home = Arrays.asList(shome);

    sfriends = res.getStringArray(R.array.elements_Portugues);
    friends = Arrays.asList(sfriends);

    snotifs = res.getStringArray(R.array.elements_Matemática);
    notifs = Arrays.asList(snotifs);
    // Add to hashMap
    listDataChild.put(listDataHeader.get(0), home); // Header, Child data
    listDataChild.put(listDataHeader.get(1), friends);
    listDataChild.put(listDataHeader.get(2), notifs);
    System.out.println (listDataHeader.get(0));




}

 >Gostaria de saber se é possivel pegar o que retorna no print ,para uma string
    
asked by anonymous 11.07.2017 / 14:41

1 answer

1

listDataHeader was initialized like this:

listDataHeader = Arrays.asList(headers);

As headers is a String array

String[] headers = res.getStringArray(R.array.nav_drawer_labels);

So, the items of listDataHeader are String.

So you can assign a String variable the value of any of these items:

String dataHeader = listDataHeader.get(0);
    
11.07.2017 / 14:58