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. 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!


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


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


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

链接地址: http://www.djcxy.com/p/4460.html

上一篇: 如何从当前的Git工作树中删除本地(未跟踪)的文件?

下一篇: 活动之间的更改不起作用