4

In my android list page/activity I have a 2 text fields a main and subsection one above each other, but when it coems to creating the array string for it I only see examples with the one section of text.

 <resources>
    <string name="hello">Hello!</string>
 </resources>

To then create what I want I would do a if statement to match the title then if so add the subtitle, but I would like to have it so I can read my title and subtitle strings something like below:

  <resources>
      <string name="hello">
          <item>Hello!</item>
          <item>my subtitle </item>
      </string>
      <string name="hello">
          <item>Hello!</item>
          <item>my subtitle </item>
      </string>
  </resources>

But I cannot find an example of how to read this to a list item etc, so I do not need to do a long if statement within my java to match the subtitle to the title.

Many Thanks Si

1 Answer 1

3

I usually delimit the text with a pipe | and split it when displaying. Its a bit ugly, but it works.

<item>item1|item2</item>

then when I call it in getView(...)

String[] r = c.getResources().getStringArray(R.array.arraylist).split("\\|");

then I have defines for the index:

private final int VIEW_HEADING_TITLE = 0;
private final int VIEW_HEADING_SUB = 1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.