Figured it out. I thought android will automatically create id's for
dynamically created UI elements. Thats why I put

*
input1.setNextFocusDownId(input2.getId());

Here I was not assigning any id explicitly for "input2".

If I set explicitly some id to "input2" and the set the next focus down id,
it worked.
*



On Wed, Sep 1, 2010 at 4:31 PM, Shashidhar <[email protected]> wrote:

> Hi,
>   In My code I have an alter window in which I take a mac address as input.
> For this I have created 6 Edit texts to accept mac address. Now my problem
> is When I am in first edit text and click on "next" button in soft
> keyboard it does not take the focus to the next available edittext. I have
> set the next focus down id for Each of the Edit text to be its next Edit
> text. But still its not working. Please Help me.
>
> I am posting the code here.
> _____________________________________________________________________
> *main.xml*
> *______________________________________________________________________*
> *
> *
> *
> <?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"
>     >
> <TextView
>     android:layout_width="fill_parent"
>     android:layout_height="wrap_content"
>     android:text="@string/hello"
>     />
>     <Button android:id="@+id/button"
>      android:layout_width ="wrap_content"
>      android:layout_height="wrap_content"
>      android:text="Click Me"
>     />
> </LinearLayout>
>
>
>
> __________________________________________________________________
>
> Activity File
> ___________________________________________________________________
>
> public class Test extends Activity {
>     /** Called when the activity is first created. */
>  private Button b;
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         b = (Button) findViewById(R.id.button);
>         b.setOnClickListener(new OnClickListener(){
>
> public void onClick(View v) {
>
> AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());
>
> alert.setTitle("Dialog");
>  alert.setMessage("Enter MAC");
>
> // Set an EditText view to get user input
>  final EditText input1 = new EditText(v.getContext());
>  final EditText input2 = new EditText(v.getContext());
>  final EditText input3 = new EditText(v.getContext());
>  final EditText input4 = new EditText(v.getContext());
>  final EditText input5 = new EditText(v.getContext());
>  final EditText input6 = new EditText(v.getContext());
>  input1.setNextFocusDownId(input2.getId());
>  input2.setNextFocusDownId(input3.getId());
>  input3.setNextFocusDownId(input4.getId());
>  input4.setNextFocusDownId(input5.getId());
>  input5.setNextFocusDownId(input6.getId());
>  input1.setImeOptions(5);
>  input2.setImeOptions(5);
>  input3.setImeOptions(5);
>  input4.setImeOptions(5);
>  input5.setImeOptions(5);
>  input6.setImeOptions(6);
>
>  final TextView tv1 = new TextView(v.getContext());
>  tv1.setText(":");
>  tv1.setTextSize(15);
>  final TextView tv2 = new TextView(v.getContext());
>  tv2.setText(":");
>  final TextView tv3 = new TextView(v.getContext());
>  tv3.setText(":");
>  final TextView tv4 = new TextView(v.getContext());
>  tv4.setText(":");
>  final TextView tv5 = new TextView(v.getContext());
>  tv5.setText(":");
>  final TextView tv6 = new TextView(v.getContext());
>  final TextView emptytv = new TextView(v.getContext());
>  emptytv.setText("  ");
>  emptytv.setWidth(2);
>
> InputFilter[] FilterArray = new InputFilter[1];
>  FilterArray[0] = new InputFilter.LengthFilter(2);
>  input1.setFilters(FilterArray);
>  input2.setFilters(FilterArray);
>  input3.setFilters(FilterArray);
>  input4.setFilters(FilterArray);
>  input5.setFilters(FilterArray);
>  input6.setFilters(FilterArray);
>
> int width = 40;
>  input1.setWidth(width);
>  input2.setWidth(width);
>  input3.setWidth(width);
>  input4.setWidth(width);
>  input5.setWidth(width);
>  input6.setWidth(width);
>
> input1.setSingleLine(true);
>  input1.setSingleLine(true);
>  input2.setSingleLine(true);
>  input3.setSingleLine(true);
>  input4.setSingleLine(true);
>  input5.setSingleLine(true);
>  input6.setSingleLine(true);
>
> int inputTextSize = 15;
>  input1.setTextSize(inputTextSize);
>  input2.setTextSize(inputTextSize);
>  input3.setTextSize(inputTextSize);
>  input4.setTextSize(inputTextSize);
>  input5.setTextSize(inputTextSize);
>  input6.setTextSize(inputTextSize);
>
> final LinearLayout ll = new LinearLayout(v.getContext());
>  ll.addView(emptytv);
>  ll.addView(input1);
>  ll.addView(tv1);
>  ll.addView(input2);
>  ll.addView(tv2);
>  ll.addView(input3);
>  ll.addView(tv3);
>  ll.addView(input4);
>  ll.addView(tv4);
>  ll.addView(input5);
>  ll.addView(tv5);
>  ll.addView(input6);
>  ll.addView(tv6);
>
>
> alert.setView(ll);
>
> alert.setPositiveButton("Save", new DialogInterface.OnClickListener() {
>  public void onClick(DialogInterface dialog, int whichButton) {
>  InputMethodManager imm =
> (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
>  imm.hideSoftInputFromWindow(input1.getWindowToken(), 0);
>  String value1 = input1.getText().toString().trim();
>  String value2 = input2.getText().toString().trim();
>  String value3 = input3.getText().toString().trim();
>  String value4 = input4.getText().toString().trim();
>  String value5 = input5.getText().toString().trim();
>  String value6 = input6.getText().toString().trim();
>  Log.i(getClass().getName(), "New
> mac:"+value1+":"+value2+":"+value3+":"+value4+":"+value5+":"+value6);
>  }
> });
>
> alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
>  public void onClick(DialogInterface dialog, int whichButton) {
>  InputMethodManager imm =
> (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
>  imm.hideSoftInputFromWindow(input1.getWindowToken(), 0);
>  }
> });
>
> alert.show();
>  }
>
>         });
>     }
> }
>
>
>
> Thanks,
> Shashidhar
> *
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to