片段不兼容类型错误:Android Studio

时间:2015-11-26 22:08:40

标签: java android android-fragments

免责声明:Android Level =初学者 我想在android中使用PApplet。我按照this指南在Android Studio中设置了项目

MainActivity.java

package com.example.jess.processingtest;


import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        FragmentManager fragmentManager = getFragmentManager();
        Fragment fragment;
        fragment = new Sketch();
        fragmentManager.beginTransaction()
                .replace(R.id.container, fragment)
                .commit();

        setContentView(R.layout.activity_main);
    }
}

Sketch.Java

package com.example.jess.processingtest;


import processing.core.PApplet;

public class Sketch extends PApplet {

//    @Override
    public void settings() {
        //Call size/fullscreen from here
        size(1000, 1000, P2D);
    }

    @Override
    public void setup() {
        //Initialize one time stuffs here
    }

    @Override
    public void draw() {
        //Finally draw from here
    }
}

错误显示为fragment = new Sketch(); ,说明不兼容的类型。我也尝试使用 import android.support.v4.app.Fragment; ,它仍然给我同样的错误。

0 个答案:

没有答案