I have set the button id in xml file but while I tried to find the id of the button it showing an error xml file
<androidx.appcompat.widget.AppCompatButton
android:id="@ id/btnrotation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rorationbtn"
android:layout_below="@ id/imgbox"
android:layout_centerInParent="true"
android:layout_marginTop="50dp">
</androidx.appcompat.widget.AppCompatButton>
java file
public class rotation extends AppCompatActivity {
AppCompatButton rotate;
ImageView imgbox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rotation);
getSupportActionBar().setTitle("Rotation");
imgbox=findViewById(R.id.imgbox);
rotate=findViewById(R.id.btnrotation);
}
error does not contain a declaration with id 'btnrotation'
CodePudding user response:
Just rebuild your project and run again
CodePudding user response:
Sometimes it is a bug in android studio, you can try close and reopen Android Studio. If it doesn't work, you can invalidate caches or clean project and rebuild it.
CodePudding user response:
Just click on Invalidate Caches from top Toolbar (File) , and then click on Invalidate & Restart. Thank You