KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've got an annoying issue with a screen. The screen consists of a bunch of Spinners one under the other, and then underneath the spinner, an EditText. The problem is that when the screen starts, the EditText has focus, meaning that some Spinners are off the top of the screen. Try as I might, I cannot make the top Spinner start focused, either by using <requestFocus/> in the screen XML, or by using requestFocus() in code. I've attempted to do what requestFocus skipping next EditText suggests, and if I'm following the suggestion correctly, it doesn't work either. To reproduce the issue, create a new Android project in Eclipse. main.xml is <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Spinner android:id="@+id/spinner" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <requestFocus /> </Spinner> <EditText android:id="@+id/edittext" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> The activity code is package nz.co.kb.testspinner; import android.app.Activity; import android.os.Bundle; import android.view.View; public class TestSpinner extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); View view = getLayoutInflater().inflate(R.layout.main, null); final View spinner = view
Tags (comma-separated)
Save Edits
Cancel