Java Android:在片段中启动活动

Java Android:在片段中启动活动,java,android,android-activity,Java,Android,Android Activity,我是android开发新手。现在我的操作栏中有选项卡。我已经为这些片段创建了类。我的第一堂课目前只有一个按钮。我以后再补充。当你点击一个按钮时,我试图在这个类中启动一个活动,但它不起作用……它只是崩溃了。下面是代码: package com.cydeon.plasmamodz; import com.cydeon.plasmamodz.R; import android.app.Activity; import android.app.Fragment; import android.cont

我是android开发新手。现在我的操作栏中有选项卡。我已经为这些片段创建了类。我的第一堂课目前只有一个按钮。我以后再补充。当你点击一个按钮时,我试图在这个类中启动一个活动,但它不起作用……它只是崩溃了。下面是代码:

package com.cydeon.plasmamodz;

import com.cydeon.plasmamodz.R;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

  public class ThemeFragment extends Fragment {

   @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.theme_frag,
            container, false);
    Button button = (Button) view.findViewById(R.id.button1);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(getActivity(), Themes.class);
            getActivity().startActivity(intent);
        }
    });

    return view;
}}

我确实在清单中定义了themes类。我不确定我做错了什么,我真的需要一些帮助。正如我所说,我才15岁,还不熟悉这一点。

我的代码很好。我开始在我的ThemeFragment类中创建Themes类,但后来创建了一个新类,并忘记删除它。现在一切正常。

“它只是崩溃了”。你有错误吗?如果是,请添加准确的错误消息。