Error when setting EditText to onClick in activity_main on Android

Asked 2 years ago, Updated 2 years ago, 86 views

An error occurs when you set EditText to onClick in activity_main on Android.
The code is as follows, and if you erase the onClick code, you will not get an error.
Please let me know if you know more.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android: orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android: orientation="horizontal">

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android: inputType="text|textNoSuggestions"
            android:onClick="clearUrl"
            android: id="@+id/urlText"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="showWebsite"
            android:text="Browse"/>
    </LinearLayout>

    <WebView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android: id="@+id/myWebView"
        android:layout_weight="1">/WebView>

</LinearLayout>

android java android-layout

2022-09-30 19:40

2 Answers

Is it the same thing as here?
Android EditText onClick Listener defined in Layout fails with Obscure Exception-Stack Overflow

v22.1.0 or later (according to the above URL description, it was found to have occurred in 22.1.0, 22.1.1, 22.2.0) It seems to be a bug in the support library.

If there are few, you might want to correct the XML-based handler configuration.

If there are a lot of fixes, using an older version (22.0.0) that doesn't cause problems may be a preliminary step.


2022-09-30 19:40

The method with clearUrl(View) does not appear to be found in Activity. Is the clearUrl method defined?


2022-09-30 19:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.