listDataHeader for a String

Asked

Viewed 15 times

0

I wonder if it is possible to return my listDataHeader to a string, because in my system.out it returns the value , but I don’t know how to pass 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
  • Have you tried String dataHeader = listDataHeader.get(0);?

  • Yeah, it worked, thank you very much, sorry for the silly question..

1 answer

1


listDataHeader was initialized so:

listDataHeader = Arrays.asList(headers);

as headers is a String array

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

therefore, the items of listDataHeader saint string.

Thus, you can assign to a String variable the value of any of these items:

String dataHeader = listDataHeader.get(0);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.