Activity_main.xml is not updated in Android studio 1.5 -


i editing ui in content_main.xml when try access button in mainactivity.java throws null pointer exception because entries there in content file not in activity file should access buttons added in content file.

in mainactivity:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     button button = (button) findviewbyid(r.id.mybutton); } 

and in activity_main.xml:

<android.support.design.widget.coordinatorlayout 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:fitssystemwindows="true" tools:context="com.example.myapplication.mainactivity">  <include layout="@layout/content_main" />  </android.support.design.widget.coordinatorlayout> 

and in content_main.xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.myapplication.mainactivity" tools:showin="@layout/activity_main">  <button     android:layout_width="100dp"     android:layout_height="100dp"     android:id="@+id/mybutton"/>  </relativelayout> 

Comments