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;
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
add a comment |
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
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
add a comment |
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
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
android android-layout android-resources
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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));
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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));
add a comment |
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));
add a comment |
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));
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));
answered Mar 26 at 11:01
PrincePrince
1,50412 silver badges30 bronze badges
1,50412 silver badges30 bronze badges
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Mar 26 at 10:49
LiarLiar
9611 gold badge7 silver badges17 bronze badges
9611 gold badge7 silver badges17 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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