2011-10-12 52 views
0

我的程序运行不正常,我不明白为什么,请介意帮忙吗?尽管build没有错误,但发生了强制停止?

package project.ernest; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class Part1 extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
    } 
    Intent DisclaimerHandler = new Intent(getBaseContext(), Part2.class); 
    { 
    Part1.this.startActivity(DisclaimerHandler); 
    } 
} 

我有2个.java文件,即Part1和Part2。 以及一个.xml文件名称放置在布局

我试图运行它,但它给了我一个力量停止。

+0

你会介意在logcat中粘贴堆栈跟踪吗? – Farhan

+0

你在Logcat中遇到了什么错误。 –

+0

抱歉,我是新的Logcat,我如何导航到那里? – FreshMeat

回答

0

使用这样的..

package project.ernest; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class Part1 extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     final Button gs = (Button) findViewById(R.id.save); 
     gs.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      Intent i = new Intent(getBaseContext(), Part2.class);   
      Part1.this.startActivity(i);  
     } 
    });   
} 
+0

现在与您的代码,我可以进入我的应用程序已经。 – FreshMeat

+0

但它失败的时刻我点击免责声明 – FreshMeat

+0

这是我已经命名的按钮之一 – FreshMeat

0

很难说没有任何logcat中,但我会尝试猜测。可能你忘了在你的Manifest文件中声明你的Part2活动。希望我是对的。

+0

FreshMeat

+0

是正确的方法吗? – FreshMeat

+0

@ user990571,name应该包含您的包名称的全名,如com.google.android.SomeClass。 – Egor

相关问题