活动之间的更改不起作用

发布于 2024-11-05 08:17:00 字数 2183 浏览 0 评论 0原文

我试图在 Android 应用程序 (2.1-update1) 中的活动之间进行更改,但它不起作用。 有什么建议吗?

当我调试应用程序时发生的唯一事情是它停止在 Instrumentation.java 中的这部分代码上:

public void waitForIdle() {
            synchronized (this) {
                while (!mIdle) {
                    try {
                        wait();
                    } catch (InterruptedException e) {
                    }
                }
            }
        }

Eclipse 说它位于 Thread 1 中

Instrumentation.checkStartActivityResult(int, Object) 行:1537。如果我 恢复应用程序,下一站是在 ZygoteInit.java 中尝试运行 可抛出的原因 = ex.getCause(); ...日食说 ZygoteInit$MethodAndArgsCaller.run() 行:864。

这是源代码: HappyHomes.java

package com.example.app;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class HappyHomes extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button login = (Button) findViewById(R.id.btnLogin);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ProgressDialog laddRuta = ProgressDialog.show(HappyHomes.this, "",
                        "Loggar in, vänligen vänta...", true);

                Intent myIntent = new Intent(view.getContext(), Kategorier.class);
                myIntent.
                        startActivity(myIntent);
            }
        });
    }
}

Kategorier.java

package com.example.app;

import android.app.Activity;
import android.os.Bundle;

public class Kategorier extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.kategorier);
    }
}

感谢您的帮助!

I'm trying to change between activities in my Android app (2.1-update1), but it doesn't work.
Any suggestions?

The only thing that happens when I debug the app is that it stops on this part of the code in Instrumentation.java:

public void waitForIdle() {
            synchronized (this) {
                while (!mIdle) {
                    try {
                        wait();
                    } catch (InterruptedException e) {
                    }
                }
            }
        }

Eclipse says that it is in Thread 1 on

Instrumentation.checkStartActivityResult(int, Object) line: 1537. If I
resume the app, the next stop is in ZygoteInit.java trying to run
Throwable cause = ex.getCause(); ... Eclipse says
ZygoteInit$MethodAndArgsCaller.run() line: 864.

Here is the source code:
HappyHomes.java

package com.example.app;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class HappyHomes extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button login = (Button) findViewById(R.id.btnLogin);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ProgressDialog laddRuta = ProgressDialog.show(HappyHomes.this, "",
                        "Loggar in, vänligen vänta...", true);

                Intent myIntent = new Intent(view.getContext(), Kategorier.class);
                myIntent.
                        startActivity(myIntent);
            }
        });
    }
}

Kategorier.java

package com.example.app;

import android.app.Activity;
import android.os.Bundle;

public class Kategorier extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.kategorier);
    }
}

Thanks for helping!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

盛夏已如深秋| 2024-11-12 08:17:00

确保 Kategorier 已在您的 AndroidManifest.xml 文件中注册。

Make sure that Kategorier is registered in your AndroidManifest.xml file.

酒浓于脸红 2024-11-12 08:17:00

将 myIntent.startActivity(myIntent); 更改为 HappyHomes.this.startActivity(myIntent);

Change myIntent.startActivity(myIntent); to HappyHomes.this.startActivity(myIntent);

梦在夏天 2024-11-12 08:17:00

Intent 类中没有任何 startActivity() 方法。你一定做错了。
只需编写 startActivity(myIntent)

There is no any startActivity() method in Intent class . you must be doing wrong.
just write startActivity(myIntent)

故人爱我别走 2024-11-12 08:17:00

所有服务、广播接收器和活动都必须在清单文件中声明。

All the Services, Broadcast Receivers and Activites must be declared in manifest file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文