I need to on the start of the Activity
my EditText
has the readonly
mode so I do it like below:
xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="@dimen/edge_offset"
android:paddingLeft="@dimen/edge_offset"
android:paddingStart="@dimen/edge_offset"
android:paddingRight="@dimen/edge_offset"
android:paddingEnd="@dimen/edge_offset"
android:paddingTop="@dimen/edge_offset"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<EditText
android:id="@+id/hometask_edt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:gravity="top|start"
android:scrollHorizontally="false"
android:hint="@string/label_summary"/>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>
Activity
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBinder = DataBindingUtil.setContentView(this, R.layout.activity_hometask);
// Setup EditText
mBinder.hometaskEdt.setInputType(InputType.TYPE_NULL);
}
When the user clicks a menu item the EditText
must be editable again. I try to make it so:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.action_edit) {
mBinder.hometaskEdt.setInputType(InputType.TYPE_CLASS_TEXT);
mBinder.hometaskEdt.invalidate();
return true;
}
return super.onOptionsItemSelected(item);
}
But, of course, it doesn't work =( What do I doing wrong?