I have 4 text boxes and when the user clicks a button i wish to insert the relevant text and move on to the next text box and insert the next text in that box. i have got some distance my code so far is.
Time1Btn = (Button)findViewById(R.id.Time1Btn);
Time2Btn = (Button)findViewById(R.id.Time2Btn);
Time1HrEB = (EditText)findViewById(R.id.Time1HrEB); // i would guess this would be replaced
Time1Btn.setOnClickListener(MyOnClickListener);
Time2Btn.setOnClickListener(MyOnClickListener);
private View.OnClickListener MyOnClickListener = new OnClickListener(){
public void onClick(View v){
Button b = (Button)v;
EditText e = (EditText).getCurrentFocus(); // attemt of what to do
String buttonText = b.getText().toString();
e.setText(buttonText); // this is the line i wish to replace.
int id = getCurrentFocus().getNextFocusRightId();
findViewById(id).requestFocus();
}
};
my layout file is.
<EditText
android:id="@+id/Time1HrEB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:maxWidth="30dp"
android:minWidth="30dp"
android:nextFocusRight="@+id/Time2HrEB"
>
</EditText>
<EditText
android:id="@+id/Time2HrEB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:minWidth="30dp"
/>
etc...
any ideas… i have tryed some things…
you are close
give it a try and let me know.