捆绑savedIntanceStatem“错误”

时间:2014-11-14 15:42:01

标签: android eclipse

我的代码:

import android.app.Fragment;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.KeyEvent;
import android.widget.Button;

public class KlassenActivity extends ActionBarActivity  {

    @Override
        protected void onCreate(Bundle savedIntanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_5aklassen);

            if(savedInstanceState == null) {

            } else {

            }

    }

我已经尝试了很多,但我无法找到我做错的事情......

帮助我!!!

错误出现在

行中
super.onCreate(savedInstanceState);

这是错误:

"savedInstanceState cannot be resolved to a variable"

整个代码(在progess:D中):

package com.example.hvt;


import android.app.Fragment;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.KeyEvent;
import android.widget.Button;

public class KlassenActivity extends ActionBarActivity  {

PlaceholderFragment taskFragement;

@Override
    protected void onCreate(Bundle savedIntanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_5aklassen);

        if(savedInstanceState == null) {
            taskFragement=new PlaceholderFragment();
            getSupportFragmentManager

        } else {

        }

    }

    public boolean onKeyDown (int keycode, KeyEvent event) {
        if (keycode == KeyEvent.KEYCODE_BACK) {
            setContentView(R.layout.activity_main);
            startActivity(new Intent(KlassenActivity.this,MainActivity.class));
        }
        return false;
    }

    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }
        @Override
        public void onActivityCreated(Bundle savedInstancesState) {
            super.onActivityCreated(savedInstanceState);
            setRetainInstance(true);
        }
    }
    public static class TechCrunchTask extends AsyncTask<Void, Void, Void> {

        @Override
        protected Void doInBackground(Void...params) {
            return null;

        }
    }

}

1 个答案:

答案 0 :(得分:2)

在函数声明中,savedInstanceState拼写错误为savedIntanceState