On my Android App there is a EditText which is supposed to keep numeric values; that’s why I defined it as
<EditText android:layout_width="fill_parent" android:id="@+id/TextNumb"
android:layout_height="wrap_content" android:gravity="right|center" android:maxLines="1"
android:maxLength="10" android:inputType="number|numberSigned|numberDecimal"/>
But at a certain point of my App I want to clear it, so in my Activity I call this EditText View and I write:
mEditView.setText("");
But I get a run-time error…how could I fix it? Is there a way to clean it?
You shan’t get runtime error calling
mEditView.setText("");. If you do, then you do something wrong outside this expression, and we need your code to tell what specifically. My guess would be not initializedmEditView(NullPointerException) or callingsetTexton different thread than UI (java.lang.RuntimeException).