in Education by
i was trying to work out on my spinner tutorial but it doesnt seem to show the header. can anyone guide me on which part that i might have overlook? public class HelloSpinnerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); spinnertest = (Spinner) findViewById(R.id.Spinner01); ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.Planets, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnertest.setAdapter(adapter); spinnertest.setOnItemSelectedListener(new MyOnItemSelectedListener()); } public class MyOnItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Toast.makeText(parent.getContext(), "The planet is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } public void onNothingSelected(AdapterView parent) { // Do nothing. } } } main.xml strings.xml Spinner Select a planet Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Not quite sure if this is possible solution will help (you may have a particular reason to try it your way), but in the past I've just added the Prompt text to the top of the Spinner string-array (at position 0), and then it shows by default in the widget. Then, in 'onItemSelected', I ignore anything if pos == 0.

Related questions

0 votes
    i was trying to work out on my spinner tutorial but it doesnt seem to show the header. can anyone ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    In my app I'm using a spinners to let the user select an item from a list. Everything works fine ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I have two buttons in MainActivity, the first one opens a custom DialogFragment with some spinners and in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    In the accompanying diagram, a fair spinner is placed at the centre O of the circle. Diameter AOB and radius OC ... in the region X? Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    I just updated to Android Studio 3.4 (Canary 5). Then I opened my existing project (which worked ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I'm looking at making an custom Android object Serializable. Should be simple I just cannot find a easy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have this code JSONObject event = new JSONObject(); Bundle bundle = new Bundle(); bundle.putString(" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I've made a fresh eclipse reinstall + Android SDK v4.0. I am trying to create a new 4.0 AVD ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I have a custom toast notification which has an image and text. The custom toast works fine however I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I'm trying to execute the following command: arp -a and I would like to redirect the output to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle. ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Yesterday I installed bash on Windows 10 and also installed Git on it. It works perfectly fine. Following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have a main activity which contains the action bar with 3 menu buttons in it. I then have a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I've noticed on Marshmallow (e.g. Nexus 6P) and also on some more recently updated Lollipop phones ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
...