开发者

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!


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


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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜