This is my problem right now, guys.
I have the next TextView and EditText
activity_profile.xml
<TextView
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/done"
android:id="@+id/done_profile_btn"
android:textColor="@color/white"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="@+id/input_profile_swift"
android:hint="@string/swift"
android:inputType="textCapCharacters"
android:textColor="@color/colorPrimaryDark"
android:layout_marginBottom="22dp"
android:maxLines="1"
android:imeOptions="actionDone"/>
And I would like to change the action that press the 'Done' button on the keyboard does for the EditText in order to do the same as the TextView, which does the next:
ProfileActivity.java
done_btn = (TextView) findViewById(R.id.done_profile_btn);
swift = (EditText)findViewById(R.id.input_profile_swift);
done_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
//saveChanges();
//finish();
Toast.makeText(getApplicationContext(), "Your changes have been saved", Toast.LENGTH_SHORT).show();
}
});
...
So... I want that both (press 'Done' on my keyboard and press the TextView) do the same.
Any idea of how to do that? Thank you very much.
You can use this one also (sets a special listener to be called when an action is performed on the EditText), it works both for DONE and RETURN:
Hope it will help !