2 for 2012 for_2012 于 2013.03.26 14:14 提问

构造函数intent报错 undefined

使用fragment中有一个下拉列表,我想在选择下拉列表项目时启动一个新activity。结果报错:

The constructor Intent(UserHomeActivity, Class) is undefined UserHomeActivity.java /SwipeyTabs/src/com/recscores/android line 28 Java Problem

实现代码:

public class UserHomeActivity extends SherlockFragment{

Spinner spinnerTeam;
Spinner spinnerLeague;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    View view =inflater.inflate(R.layout.user_home, container, false);


    // Team Spinner
    spinnerTeam = (Spinner)view.findViewById(R.id.spinner_team);
    spinnerTeam.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { 
            **Intent ii = new Intent(UserHomeActivity.this,TeamHomeActivity.class);
            startActivity(ii); **
        } 

        public void onNothingSelected(AdapterView<?> adapterView) {
            return;
        } 
    }); 

1个回答

guoleimail
guoleimail   2013.04.10 16:44

请检查下你的UserHomeActivity 有没有在ANDROIDMANIFEST.XML中定义过,

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!