简体   繁体   English

活动之间的变化不起作用

[英]Change between activities does not work

I'm trying to change between activities in my Android app (2.1-update1), but it doesn't work. 我正在尝试在我的Android应用程序(2.1-update1)中的活动之间进行更改,但它不起作用。 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: 调试应用程序时唯一发生的事情就是它停止在Instrumentation.java中的这部分代码:

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

Eclipse says that it is in Thread 1 on Eclipse说它在Thread 1上

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(); Instrumentation.checkStartActivityResult(int,Object)行:1537。如果我恢复应用程序,下一站是在ZygoteInit.java中试图运行Throwable cause = ex.getCause(); ... Eclipse says ZygoteInit$MethodAndArgsCaller.run() line: 864. ... Eclipse说ZygoteInit $ MethodAndArgsCaller.run()行:864。

Here is the source code: HappyHomes.java 这是源代码: 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 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! 谢谢你的帮助!

确保在AndroidManifest.xml文件中注册了Kategorier

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

There is no any startActivity() method in Intent class . Intent类中没有任何startActivity()方法。 you must be doing wrong. 你一定做错了。 just write startActivity(myIntent) 只需编写startActivity(myIntent)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在活动之间传输int不能正常工作 - Transfering int between activities does not work correctly 在活动之间更改 TextView - Change TextView Between Activities Android在Galaxy Note上的Activity(Singleton)之间传递数据不起作用 - Android passing data between Activities (Singleton) on Galaxy Note does not work 在不同的活动之间开始活动的结果不起作用 - Start activity for result not work, between different activities 无法在两个活动之间更改TextView? - Cannot change TextView between two activities? 如何在两个活动之间改变主要任务? - How to change the main task between two activities? Android通过ActionBar在Asynctask中的活动之间进行更改(切换) - Android Change(switch) between activities in Asynctask with ActionBar 如何使用微调器值在活动之间进行更改(android studio) - how to use spinner value to change between activities(android studio) 在 Android 中的两个活动之间切换时更改布局中的可见性 TextView - Change visibility TextView in layout when switch between two activities in Android setDisplayHomeAsUpEnabled 在我的一项活动中不起作用,但在其他任何地方它都起作用 - setDisplayHomeAsUpEnabled not working in one of my Activities but everywhere else it does work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM