I am getting error when open new activity on button click android studio : <p>i created one android project . i tried to open new activity. but i got error.</p>

<p>my code:</p>

<pre><code> &lt;Button
    android:text="Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="141dp"
    android:id="@+id/btn1"
    android:onClick="onClickA" /&gt;

public void onClickA()
{
    startActivity(new Intent(this,LoginActivity.class));
}
</code></pre>

<p>error </p>

<pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.myapp.i, PID: 1635
 java.lang.IllegalStateException: Could not find method onClickA(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'btn1'
   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:327)
   at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
   at android.view.View.performClick(View.java:5609)
   at android.view.View$PerformClick.run(View.java:22259)
   at android.os.Handler.handleCallback(Handler.java:751)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6077)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
</code></pre>

<p>can you help to solve this error.
thank you.</p>
