Note that there are some explanatory texts on larger screens.

plurals
  1. POSubstitute for if statements when using Constants
    primarykey
    data
    text
    <p>I think the best way to describe my question, is to describe what I am doing first.</p> <p>I have a simple activity with 3 listpick options (Buttons that launch a listview). Each ListPicker has 8 items in the ListView.</p> <p>Each Item in the Listview, let's call it a value of Name, has a corresponding Address and Phone.</p> <p>So here are the example of the constatns I am using</p> <pre><code>public final String GROUP_1_VENUE_1_NAME = "1name1"; public final String GROUP_1_VENUE_1_ADDRESS = "1address1"; public final String GROUP_1_VENUE_1_PHONE = "1phone1"; public final String GROUP_1_VENUE_2_NAME = "1name2"; public final String GROUP_1_VENUE_2_ADDRESS = "1address2"; public final String GROUP_1_VENUE_2_PHONE = "1phone2"; public final String GROUP_1_VENUE_3_NAME = "1name3"; public final String GROUP_1_VENUE_3_ADDRESS = "1address3"; public final String GROUP_1_VENUE_3_PHONE = "1phone3"; ..... public final String GROUP_2_VENUE_1_NAME = "2name1"; public final String GROUP_2_VENUE_1_ADDRESS = "2address1"; public final String GROUP_2_VENUE_1_PHONE = "2phone1"; public final String GROUP_2_VENUE_2_NAME = "2name2"; public final String GROUP_2_VENUE_2_ADDRESS = "2address2"; public final String GROUP_2_VENUE_2_PHONE = "2phone2"; .... public final String GROUP_3_VENUE_1_NAME = "3name1"; public final String GROUP_3_VENUE_1_ADDRESS = "3address1"; public final String GROUP_3_VENUE_1_PHONE = "3phone1"; public final String GROUP_3_VENUE_2_NAME = "3name2"; public final String GROUP_3_VENUE_2_ADDRESS = "3address2"; public final String GROUP_3_VENUE_2_PHONE = "3phone2"; ... </code></pre> <p>So an item gets picked from a listPicker, and now I want to evaluate the result</p> <p>I have 3 Strings that need to be set; name, address, and phone</p> <p>so right now I have something like this...</p> <pre><code>if (selection.equals(GROUP_1_VENUE_1_NAME) { name = GROUP_1_VENUE_1_NAME; address = GROUP_1_VENUE_1_ADDRESS; phone = GROUP_1_VENUE_1_PHONE; } else if (selection.equals(GROUP_1_VENUE_2_NAME) { name = GROUP_1_VENUE_2_NAME; address = GROUP_1_VENUE_2_ADDRESS; phone = GROUP_1_VENUE_2_PHONE; } else if ..... </code></pre> <p>and so on and so forth.</p> <p>So, here is my question. Is there any easier way to do this that allows me to evaluate if the selection equals one of the NAME CONSTANTS and if so, set the corresponding values?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload