メインアクティビティからログインアクティビティにボタンログインする必要があります。私はすべての手順に従いましたが、デバイスでテストしてもまだ動作しません。他のアクティビティに変更することができません
このmain.javaある:
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
}
Logcat:
12-06 19:57:03.960 6374-6374/com.example.ancaalexandra.proiectandroidd D/[email protected][MainActivity]: ViewPostImeInputStage processPointer 0
12-06 19:57:03.961 6374-6374/com.example.ancaalexandra.proiectandroidd E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
12-06 19:57:03.961 6374-6374/com.example.ancaalexandra.proiectandroidd V/BoostFramework: BoostFramework() : mPerf = null
12-06 19:57:04.046 6374-6374/com.example.ancaalexandra.proiectandroidd D/[email protected][MainActivity]: ViewPostImeInputStage processPointer 1
12-06 19:57:04.435 6374-6374/com.example.ancaalexandra.proiectandroidd D/[email protected][MainActivity]: ViewPostImeInputStage processPointer 0
12-06 19:57:04.522 6374-6374/com.example.ancaalexandra.proiectandroidd D/[email protected][MainActivity]: ViewPostImeInputStage processPointer 1
12-06 19:57:04.791 6374-6374/com.example.ancaalexandra.proiectandroidd D/[email protected][MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0
12-06 19:57:04.837 6374-6374/com.example.ancaalexandra.proiectandroidd D/AndroidRuntime: Shutting down VM
12-06 19:57:04.838 6374-6374/com.example.ancaalexandra.proiectandroidd E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ancaalexandra.proiectandroidd, PID: 6374
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ancaalexandra.proiectandroidd/com.example.ancaalexandra.proiectandroidd.LoginActivity}: java.lang.ClassCastException: com.example.ancaalexandra.proiectandroidd.LoginActivity cannot be cast to android.view.View$OnClickListener
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.ClassCastException: com.example.ancaalexandra.proiectandroidd.LoginActivity cannot be cast to android.view.View$OnClickListener
at com.example.ancaalexandra.proiectandroidd.LoginActivity.onCreate(LoginActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6956)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
パブリッククラスMainActivityはAppCompatActivityがView.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View v = findViewById(R.id.buttonlog);
v.setOnClickListener((View.OnClickListener) this);
}
@Override
public void onClick(View v) {
if(v.getId()==R.id.buttonlog)
{
Intent intent = new Intent(this,LoginActivity.class);
this.startActivity(intent);
}
}}
ログインアクティビティが実装延び
マニフェストファイルで両方のアクティビティを宣言しました。私は何を間違えたの?ありがとうございました!
それは働いた。ありがとうございました! – Arya1209