First of all, I apologize for my bad English Grammar.
There is a toggleButton and EditText in my Simple Android Application. When I click the toggle button editText Box change into the password field and a normal text field.
That is working perfectly, but the problem is when I click the toggle button cursor always goes to the beginning of the Text.
Example: When Type stack it shows as ..... after clicking toggle button that words appear but cursor goes into the front of 's' it does not stay after 'k'
How can I correct this issue?
This is EditText and toggle Button xml code
    <EditText
            android:id="@+id/etCommand"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:hint="@string/command"
            android:password="true" />
<ToggleButton
            android:id="@+id/tglBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="75"
            android:checked="true"
            android:onClick="changeField"
            android:paddingBottom="5dp"
            android:text="ToggleButton" />
and I change its behavior using the following code
if (passTog.isChecked()) 
    {
        input.setInputType(InputType.TYPE_CLASS_TEXT| InputType.TYPE_TEXT_VARIATION_PASSWORD);
    } 
    else 
    {
        input.setInputType(InputType.TYPE_CLASS_TEXT);
    }
Thanks in advance.
 
     
     
     
    