How to use String arrays in layouts?How to save an Android Activity state using save instance state?Fling gesture detection on grid layoutWhy is the Android emulator so slow? How can we speed up the Android emulator?Can I underline text in an Android layout?Referencing a string in a string array resource with xmlReference one string from another string in strings.xml?How to escape % in String.Format?How do I fix android.os.NetworkOnMainThreadException?What's “tools:context” in Android layout files?How to avoid reverse engineering of an APK file?

How did Jayne know when to shoot?

Is it possible to have a career in SciComp without contributing to arms research?

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

Differentiable functions and existence of limits

What makes MOVEQ quicker than a normal MOVE in 68000 assembly?

Wait or be waiting?

How can I automate this tensor computation?

What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?

Company looks for long-term employees, but I know I won't be interested in staying long

How long were the Apollo astronauts allowed to breathe 100% oxygen at 1 atmosphere continuously?

Why do jet engines sound louder on the ground than inside the aircraft?

Why do the digits of a number squared follow a similar quotient?

Batch processing/extracting raw data of one raster using one shapefile (with many polygons)?

Manager asking me to eat breakfast from now on

Do higher dimensions have axes?

Which GPUs to get for Mathematical Optimization (if any)?

May I use a railway velocipede on actively-used British railways?

In this iconic lunar orbit rendezvous photo of John Houbolt, why do arrows #5 and #6 point the "wrong" way?

Is this Android phone Android 9.0 or Android 6.0?

Real orthogonal and sign

Applying for jobs with an obvious scar

What's a German word for »Sandbagger«?

Why do space operations use "nominal" to mean "working correctly"?

How can I help our ranger feel special about her beast companion?



How to use String arrays in layouts?


How to save an Android Activity state using save instance state?Fling gesture detection on grid layoutWhy is the Android emulator so slow? How can we speed up the Android emulator?Can I underline text in an Android layout?Referencing a string in a string array resource with xmlReference one string from another string in strings.xml?How to escape % in String.Format?How do I fix android.os.NetworkOnMainThreadException?What's “tools:context” in Android layout files?How to avoid reverse engineering of an APK file?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I created a string-array in my strings.xml file and I want access array in
my layout to fill my chips. How can I do it?



This my strings.xml



<string-array name="shortcutCategoryNames">
<item>Digital</item>
<item>Clothes</item>
<item>Sport</item>
<item>Cosmetics</item>
</string-array>


This is my layout



 <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
android:id="@+id/chp_digital"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.google.android.material.chip.Chip
android:id="@+id/chp_clothes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>


</com.google.android.material.chip.ChipGroup>









share|improve this question



















  • 1





    "I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

    – CommonsWare
    Mar 26 at 10:50

















0















I created a string-array in my strings.xml file and I want access array in
my layout to fill my chips. How can I do it?



This my strings.xml



<string-array name="shortcutCategoryNames">
<item>Digital</item>
<item>Clothes</item>
<item>Sport</item>
<item>Cosmetics</item>
</string-array>


This is my layout



 <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
android:id="@+id/chp_digital"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.google.android.material.chip.Chip
android:id="@+id/chp_clothes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>


</com.google.android.material.chip.ChipGroup>









share|improve this question



















  • 1





    "I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

    – CommonsWare
    Mar 26 at 10:50













0












0








0








I created a string-array in my strings.xml file and I want access array in
my layout to fill my chips. How can I do it?



This my strings.xml



<string-array name="shortcutCategoryNames">
<item>Digital</item>
<item>Clothes</item>
<item>Sport</item>
<item>Cosmetics</item>
</string-array>


This is my layout



 <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
android:id="@+id/chp_digital"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.google.android.material.chip.Chip
android:id="@+id/chp_clothes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>


</com.google.android.material.chip.ChipGroup>









share|improve this question
















I created a string-array in my strings.xml file and I want access array in
my layout to fill my chips. How can I do it?



This my strings.xml



<string-array name="shortcutCategoryNames">
<item>Digital</item>
<item>Clothes</item>
<item>Sport</item>
<item>Cosmetics</item>
</string-array>


This is my layout



 <com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
android:id="@+id/chp_digital"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.google.android.material.chip.Chip
android:id="@+id/chp_clothes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>


</com.google.android.material.chip.ChipGroup>






android android-layout android-resources






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 12:16









Fantômas

33.4k15 gold badges66 silver badges93 bronze badges




33.4k15 gold badges66 silver badges93 bronze badges










asked Mar 26 at 10:43









Alireza BideliAlireza Bideli

361 silver badge8 bronze badges




361 silver badge8 bronze badges







  • 1





    "I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

    – CommonsWare
    Mar 26 at 10:50












  • 1





    "I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

    – CommonsWare
    Mar 26 at 10:50







1




1





"I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

– CommonsWare
Mar 26 at 10:50





"I want access array in my layout to fill my chips" -- there is no mechanism for doing that, sorry. You will need to use Java/Kotlin code to create your chips and put them in the group.

– CommonsWare
Mar 26 at 10:50












2 Answers
2






active

oldest

votes


















0














You can get String Array using below method.



ArrayList<String> tagList = new ArrayList();

String[] someArray = getResources().getStringArray(R.array.shortcutCategoryNames);
tagList.addAll(Arrays.asList(some_array));





share|improve this answer






























    0














    You can get string-array using this code:



    String strArray[] = getResources().getStringArray(R.array. shortcutCategoryNames);


    Then loop through strArray to create Chip and add those Chip to ChipGroup programmatically






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55355183%2fhow-to-use-string-arrays-in-layouts%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can get String Array using below method.



      ArrayList<String> tagList = new ArrayList();

      String[] someArray = getResources().getStringArray(R.array.shortcutCategoryNames);
      tagList.addAll(Arrays.asList(some_array));





      share|improve this answer



























        0














        You can get String Array using below method.



        ArrayList<String> tagList = new ArrayList();

        String[] someArray = getResources().getStringArray(R.array.shortcutCategoryNames);
        tagList.addAll(Arrays.asList(some_array));





        share|improve this answer

























          0












          0








          0







          You can get String Array using below method.



          ArrayList<String> tagList = new ArrayList();

          String[] someArray = getResources().getStringArray(R.array.shortcutCategoryNames);
          tagList.addAll(Arrays.asList(some_array));





          share|improve this answer













          You can get String Array using below method.



          ArrayList<String> tagList = new ArrayList();

          String[] someArray = getResources().getStringArray(R.array.shortcutCategoryNames);
          tagList.addAll(Arrays.asList(some_array));






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 11:01









          PrincePrince

          1,50412 silver badges30 bronze badges




          1,50412 silver badges30 bronze badges























              0














              You can get string-array using this code:



              String strArray[] = getResources().getStringArray(R.array. shortcutCategoryNames);


              Then loop through strArray to create Chip and add those Chip to ChipGroup programmatically






              share|improve this answer



























                0














                You can get string-array using this code:



                String strArray[] = getResources().getStringArray(R.array. shortcutCategoryNames);


                Then loop through strArray to create Chip and add those Chip to ChipGroup programmatically






                share|improve this answer

























                  0












                  0








                  0







                  You can get string-array using this code:



                  String strArray[] = getResources().getStringArray(R.array. shortcutCategoryNames);


                  Then loop through strArray to create Chip and add those Chip to ChipGroup programmatically






                  share|improve this answer













                  You can get string-array using this code:



                  String strArray[] = getResources().getStringArray(R.array. shortcutCategoryNames);


                  Then loop through strArray to create Chip and add those Chip to ChipGroup programmatically







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 10:49









                  LiarLiar

                  9611 gold badge7 silver badges17 bronze badges




                  9611 gold badge7 silver badges17 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid …


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55355183%2fhow-to-use-string-arrays-in-layouts%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                      Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?