android.widget.Button cannot be cast to android.widget.EditText

前端 未结 4 915
轮回少年
轮回少年 2021-01-12 09:36

Developing my first Android calculator application, I succeeded in updating a TextView in a new activity by passing the answer via an intent, but this requires the user to h

4条回答
  •  滥情空心
    2021-01-12 10:19

    I followed the steps in the answer (cleaned and then made sure it's the id) and noticed that going to the source of my EditText R.id brings me to the EditText. Thought this is definitely not a IDE cache problem.

    What I did do is to change the LinearLayout

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    

    to

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    

    For some reason it fixed the issue (I had this whole layout wrapped in something else that I just recently removed).

提交回复
热议问题