I have one edit text and i want to set focus on it once a button is clicked and after editing my status when enter or done is pressed for soft keyboard i want to remove focus again and send a request to server.
here is my edit text in XML
<EditText
android:id="@+id/time_statusTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/selectIBT"
android:layout_alignLeft="@+id/profile_name"
android:layout_toLeftOf="@+id/add_timeline_status_IBTN"
android:layout_toRightOf="@+id/image_profile"
android:background="@android:color/transparent"
android:focusable="false"
android:maxLines="2"
android:text="short description of \nyourself that can go\nover 2 lines."
android:textColor="@color/text_color_gray"
android:textSize="18sp" />
here what i am doing on button click
case R.id.add_timeline_status_IBTN:
time_statusTV.setFocusable(true);
time_statusTV.requestFocus();
break;
here is my Edit text key event
time_statusTV = (EditText) rootView.findViewById(R.id.time_statusTV);
time_statusTV.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if ((event.getAction() == KeyEvent.ACTION_DOWN)
&& (keyCode == KeyEvent.KEYCODE_ENTER)) {
// My code
time_statusTV.clearFocus();
}
return false;
}
});
But when I click on button nothing happens.