Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Continuing from my last comment above...</p> <p>The following code modifies <a href="http://developer.android.com/resources/tutorials/views/hello-spinner.html" rel="noreferrer">the Hello Spinner tutorial application</a> to display the spinner text contents centered horizontally, as seen in the following two screenshots.</p> <p><strong>res/layout/my_spinner_textview.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/spinnerItemStyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" /&gt;</code></pre> <pre><code>public class HelloSpinner extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, // android.R.layout.simple_spinner_item); R.layout.my_spinner_textview); // adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(R.layout.my_spinner_textview); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); } //No other modification needed.</code></pre> <p><img src="https://lh6.googleusercontent.com/_VZJksQ6kepc/TbJg4y9oZoI/AAAAAAAAAGI/zCRtLuKuyZM/s800/Q5755506_Centered_Spinner_Contents_1.png" /></p> <p><img src="https://lh4.googleusercontent.com/_VZJksQ6kepc/TbJg5cbY9DI/AAAAAAAAAGM/FHqCM64UjHE/s800/Q5755506_Centered_Spinner_Contents_2.png" /></p> <p>This hopefully provides enough direction to fix the problem.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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