2017-03-02 93 views
-7

嗨我是新的android应用程序开发项目,我已创建一个登录屏幕,旨在仪表板avtivity。我在仪表板上做了一个按钮来实现另一个活动,但是当我点击按钮而不是switchid ac时。它会崩溃并返回登录屏幕。任何帮助将被赞赏。 这是我的意图代码。不切换到下一个活动

public class Dashboard extends AppCompatActivity { 
Button button; 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_dashboard); 

    button = (Button) findViewById(R.id.cv_btn); 

    button.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      Toast.makeText(Dashboard.this, "Make your CV easy", Toast.LENGTH_LONG).show(); 
      Intent cvintent; 
      cvintent= new Intent(Dashboard.this, CV.class); 
      startActivity(cvintent); 
     } 
    }); 
} 

}按钮

<Button 
    android:id="@+id/cv_btn" 
    android:layout_width="150dp" 
    android:layout_height="wrap_content" 
    android:text="Make Your CV" 
    android:textColor="@android:color/white" 
    android:background="@color/colorPrimaryDark" 
    android:layout_margin="15dp" 
    android:textSize="16sp" 
    /> 
+1

你有没有注册清单文件,你的'CV'活动? – Piyush

+6

发布您的错误代码 –

+0

@suman粘贴您的崩溃日志,而不是xml文件 –

回答

0

我跑那些你贴没有任何问题,所有事情的来龙去脉正确的代码

xml文件。我认为你在CV活动或你的清单/构建配置中遇到了问题。

enter image description hereenter image description here