我希望用户能够点击按钮并将其带到不同的活动。我之前在其他应用中使用过类似的代码,但每次按下按钮时,应用都会崩溃。在主菜单中,我有:在Android中的活动之间切换
Button testButton = (Button) findViewById(R.id.testButton);
testButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("de.vogella.android.c2dm.simpleclient.TEST"));
}
});
在清单:
<activity
android:name=".TestClass"
android:label="@string/app_name" >
<intent-filter>
<action android:name="de.vogella.android.c2dm.simpleclient.TEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
TestClass.java是:
package de.vogella.android.c2dm.simpleclient;
import android.app.Activity;
import android.os.Bundle;
public class TestClass extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
你能还发布DDMS日志?这将有助于了解应用程序崩溃的位置。 – 2012-03-25 12:47:18
在Eclipse中使用'adb logcat',DDMS或LogCat视图来检查LogCat并查看与崩溃相关的堆栈跟踪。 – CommonsWare 2012-03-25 12:58:52
如何发布DDMS日志?我试图看看LogCat中的东西,但我不知道它的含义。这是控制台中的最后一行: [2012-03-25 13:59:46 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] C:\ Users \ Tabitha \ workspace的解析器异常\ HelloTabWidget \ AndroidManifest.xml:根元素后面的文档中的标记必须是格式良好的。 – user1260239 2012-03-25 13:04:22