Java & android: Help linking an item in a listView to its correct view, but not the way i know of.

Posted by Capsud on Stack Overflow See other posts from Stack Overflow or by Capsud
Published on 2010-06-02T01:20:33Z Indexed on 2010/06/02 1:23 UTC
Read the original article Hit count: 421

Filed under:
|
|
|

Hi, i'm developing an android app, and what i have is a String array of restaurants in one class...

static final String[] AtoZ = new String[] {

    "Ananda",
    "Brambles Cafe", "Brannigans", "Buona Sera",
    "Cafe Mao", "Cafe Mimo",
    "Dante",
    "Eddie Rockets",
    "Frango's World Cuisine",
    "Nando's",
    "Overends Restaurant @ Airfield House",
    "Pizza Hut",
    "Roly Saul",
    "Siam Thai","Smokey Joes","Sohag Tandoori",
    "TGI Friday","The Rockfield Lounge", "Winters Bar",
    "Al Boschetto","Baan Thai", "Bella Cuba", "Bellamys","Bianconis","Canal Bank Cafe",
    "Canalettos Restaurant","Chandni Restaurant", "Chill Out Cafe", "Crowes", "Da Vincenzo", "Druids", "Dylan",
    "Epic Restaurant", "Jewel in the Crown", "Juniors", "Kanum Thai","Kites", "Koishi","Maia Restaurant",
    "Mangetu Restaurant", "Millers Pizza Kitchens",
    "O'Connells Restaurant", "Ocras Restaurant", "Orchid Szechuan Restaurant", "Roly's Bistro",
    "Ryans Beggars Bush", };

i have created a view for each of these restaurants aswell in my layouts folder.

so this array is going to be displayed in a listView in my android app.

What i want to know is what is the quickest way of linking the item clicked to its correct view, without having to type out each position in the array and have a serious of if statements which would take a year with this!

i dont want to be doing something like this

if(position == 1){
        setContentView(R.layout.bentleys);

as it would take a year doing that for each one...

Please help. thanks alot.

© Stack Overflow or respective owner

Related posts about java

Related posts about android