java - Error:(21, 8) error: class MyActivity is public - Can't edit MyActivity -
when trying edit myactivity, opens mainactivity.java.
when trying change read flag error message shows up
failed change read-only flag /root/androidstudioprojects/myapplication3/app/src/main/java/xyz/adamstephenson/android/myapplication/mainactivity.java
i'm trying make public class outputs information when button pressed on android.
the error is:
error:(21, 8) error: class myactivity public, should declared in file named myactivity.java
package xyz.adamstephenson.android.myapplication; import android.app.activity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.content.intent; import static xyz.adamstephenson.android.myapplication.r.layout.activity_main; public class myactivity extends activity { protected void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(activity_main); final button button = (button) findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { log.d("button", "this message"); } }); } }
this error occurs when class file name
not same class name inside class file.
in drive make class
a.java write public class a1{}
it throw exception : class a1 public, should declared in file named a1.java
how ever if following
a.java , code class a1{}
above not throw exception, class not accessible outside package.
Comments
Post a Comment