活动之间的更改不起作用
我试图改变我的Android应用程序(2.1-update1)中的活动,但它不起作用。 有什么建议么?
我调试应用程序时发生的唯一情况是,它停在Instrumentation.java中这部分代码上:
public void waitForIdle() {
synchronized (this) {
while (!mIdle) {
try {
wait();
} catch (InterruptedException e) {
}
}
}
}
Eclipse说它在线程1中
Instrumentation.checkStartActivityResult(int,Object)行:1537.如果我恢复应用程序,下一站是在ZygoteInit.java尝试运行Throwable cause = ex.getCause(); ... Eclipse说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);
}
}
感谢您的帮助!
确保Kategorier
已在你的AndroidManifest.xml
文件中注册。
更改myIntent.startActivity(myIntent);
到HappyHomes.this.startActivity(myIntent);
Intent类中没有任何startActivity()方法。 你一定是做错了。 只需写入startActivity(myIntent)
链接地址: http://www.djcxy.com/p/4459.html上一篇: Change between activities does not work
下一篇: telephonyManager.listen forces application to terminate