1

I'm making an android application in eclipse, but I got some issues with the spinners. First of all I would like my spinner to start on no target at all. You see when I start the application the spinner already have the first item in my list selected, and I don't like that. My second issue is that I would like to link specific targets on my list to different url website, don't know really how to do that.

something like:

if item <item>"xxxx"</item> is selected
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com")));"
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
rosa_kanin
  • 11
  • 1

1 Answers1

0
  • First part: No default target in spinner
    You can have an empty string as first element in the Spinner's adapter and take care to ignore that first (0th) index in your implementation.

  • Second part: linking URL

    1. You can have a mapping for elements in Spinner's adapter with its respective URL.
    2. In onItemSelected() implementation, based on which item is selected, you select the URL from the mapping implementation and load that URL as you need.

For code you can have a look at here, its not a complete code as you need above but it can get you started.

Community
  • 1
  • 1
TheCottonSilk
  • 8,662
  • 2
  • 26
  • 37
  • Thx :) But I still don't figure out how to link different elements to different Urls in my spinner. Do you mean "onItemSelected(XXXX) startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com")));"" – rosa_kanin Jan 28 '11 at 12:55
  • You can create a WebView object say myWebView and use loadUrl() method as: myWebView.loadUrl(yourUrlString); – TheCottonSilk Jan 28 '11 at 13:01