Android auto focus change
<p>i want to have a set of buttons and the focus on buttons should change periodically first i want to try it with 2 buttons.this is my main.xml file.   </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;  
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_width="fill_parent"    
    android:layout_height="fill_parent"    
    android:orientation="vertical" &gt;    

    &lt;Button    
       android:id="@+id/number_button"    
       android:layout_width="wrap_content"    
       android:layout_height="wrap_content"   
       android:layout_gravity="center"    
       android:layout_weight="0.72"    
       android:focusable="true"      
       android:gravity="center"    
       android:text="@string/number"    
       android:textSize="10pt" android:clickable="true"  
       android:focusableInTouchMode="true"/&gt;   

  &lt;Button  
       android:text="@string/contact"    
       android:textSize="10pt"    
       android:layout_width="wrap_content"    
       android:layout_height="wrap_content"  
       android:id="@+id/contact_button"  
       android:layout_weight="1" android:layout_gravity="center"   
       android:focusable="true" android:gravity="center"  
       android:focusableInTouchMode="true"/&gt;    

&lt;/LinearLayout&gt;  
</code></pre>

<p>in the source code i have used FOCUS_LEFT,RIGHT and all other options ,but i am getting a run time exception. the orientation is set as vertical in linear layout.Please help me to sort out this problem, if anybody know how to set the timer option as well post it here</p>

<p>here is the code</p>

<pre><code>package com.example.helloandroid;

import android.app.Activity;  

import android.os.Bundle;  

import android.util.Log;  

import android.view.View;  

import android.widget.Button;  

public class HelloandroidActivity extends Activity {  

    /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        // Object o=null;  
        // o.toString();  
        // TextView tv = new TextView(this);  
        // tv.setText("Hello Andriod");  

        setContentView(R.layout.main);
        Button mybtn= (Button)findViewById(R.id.number_button);
        mybtn.requestFocus();

        try
        {
        Button mybtn2= (Button)mybtn.focusSearch(View.FOCUS_DOWN);
        mybtn2.requestFocus();

        }
        catch(Exception e)
        {

            Log.e("focus change","focus failed",e);
        }

    }
}
</code></pre>
