Im setting up a kisok App and keep getting a java.lang.NullPointerException in my WebviewActivity.
Unable to start activity ComponentInfo{eu.xx.xyc/eu.xx.xyz.ActivityWebView}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.EditText.addTextChangedListener(android.text.TextWatcher)' on a null object reference
Checking xml for "view" instead of "View" declarations. Checking if the Object has values, also if the object is instanciated. Have looked in Stackoverflow but the given solution do not work for me.
<EditText
android:layout_width="289dp"
android:layout_height="wrap_content"
android:inputType="textUri"
android:text="@string/not_set"
android:id="@+id/remoteContentURLTextField"
android:layout_below="@+id/remoteContentURL"
android:layout_alignParentStart="true" />
private EditText mRemoteContentURLEditText;
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_web_view);
connectUiElements();
setUpUiListeners();
}
private void connectUiElements() {
mRemoteContentURLEditText = (EditText) findViewById(R.id.remoteContentURLTextField);
}
mRemoteContentURLEditText.addTextChangedListener(
new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence newValue, int start,
int before, int count) {
updateRemoteContentURL(newValue.toString());
}
}
);
mRemoteContentURLEditText.setOnEditorActionListener(
new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
return false; // pass on to other listeners.
}
}
);
Im expecting it to build normally and not to be null.
Thanks for help.