code:
Using java Syntax Highlighting
- package com.google.android.samples.view;
- import com.google.android.samples.R;
- import android.app.Activity;
- import android.os.Bundle;
- public class Focus2 extends Activity {
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.focus_2);
- }
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
xml:
Using xml Syntax Highlighting
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:orientation="horizontal">
- <Button android:id="@+id/leftButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="3dip"
- android:text="@string/focus_2_left"
- android:nextFocusRight="@+id/rightButton"/> <!-- jump over middle! -->
- <Button android:id="@+id/centerButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="3dip"
- android:text="@string/focus_2_jump" />
- <Button android:id="@+id/rightButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginRight="3dip"
- android:text="@string/focus_2_right"/>
- </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
when first enter this activity, and press any key, then the first button is focused.
My questions is: how to change the code, let the second button to be focused when I first press any navigate key. I try requestFocus(), but failed.




