4

I am wondering is there a possibility to change the Title Text on my Spinner Menu?

I see the Prompt Title field id in the component, but i dont know if its possible to avoid that it always take the first row data from my arrayList....

spinner = (Spinner) findViewById(R.id.spinner);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                this, 
                android.R.layout.simple_spinner_item, 
                CategoriesConsumer.categories);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        spinner.setAdapter(adapter);
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
papachan
  • 1,891
  • 17
  • 20
  • 1
    If I get you right you want to show a custom "title" in the spinner field as long as no item was selected by the user. right? Have you ever found a way? I want to achieve the same thing... – jpm May 30 '11 at 15:14

1 Answers1

3

Hmm?

Unless I'm mistaken then you've already mentioned it. For XML inside the Spinner component:

android:prompt="This is my title"

And in code:

spinner.setPrompt("This is my title");

Not sure what you mean about avoiding that it takes row data from your ArrayList...

Codemonkey
  • 3,412
  • 3
  • 20
  • 24
  • Cool i am testing that right now! – papachan Mar 08 '11 at 15:20
  • If it doesn't then I'll be back in an hour or so when my commute from work is over ;) – Codemonkey Mar 08 '11 at 15:26
  • Look, i am trying to change the title on the layout view where the Spinner Composant is showed. The title you mean is just changed when the menu is diplayed after clicked it ! you understand? – papachan Mar 08 '11 at 16:19
  • So you're not asking how to change the title text, you're asking how to change the default selected item? Call setSelection to pick a position from your adapter. – adamp Mar 08 '11 at 16:41
  • Yes exactly adamp, I am looking for changing the default selected text on the UILayout, before it have been selected ! – papachan Mar 08 '11 at 18:44