Component ID does not appear in MainActivity

0

The problem is this: I add a component in my ActivityMain, a button for example, but when I go to do the findviewById (ID) of the component, its ID does not appear in MainActivity, it was working normal before, add a new button and its ID no longer appears, it appears in ActivityMain, I put an ID on it normal, but at the time of doing findviewById, the ID does not appear. I'm having this problem for the second, the first time I solved it, but I had to create another project, copy all the code to another project and then it was back to normal and I was able to add the component, but I did not want to have to do it for the second time, to understand why this is happening

    
asked by anonymous 29.08.2018 / 02:50

2 answers

0

The most likely problem is that you are not setting the ID attribute the correct way or it is not in the R file. Home First make sure you're setting the component's id attribute:

<Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button" />


If yes, build the project so that references are added to the R

    
29.08.2018 / 12:12
0

The problem was that Android Studio was not half that updating the components that I put, I continued the work in the code until one hour the android studio gave a small twist, then I decided to look for the component ID and it was there , in fact, the problem must have been neither Android Studio itself, but with my notebook that was overloaded with several tabs in the chrome opened as well.

    
30.08.2018 / 15:04