I have a java fragment with viewPager in it..

public class FragmentWithViewPager extends Fragment {

    private class ViewPagerAdapter extends FragmentStatePagerAdapter {

        ViewPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int i) {
            Fragment fragment = new DeshFalView(); //<-- Problem here
            Bundle args = new Bundle();
            args.putInt("index", i);
            fragment.setArguments(args);
            return fragment;
        }

    }
}

现在我有另一个片段,它将填充在上面的片段中,用kotlin写成如下:

class DeshFalView : Fragment(), DeshfalContract.View {
    //More code...
}

I do not get any lint warning or error but when I try to run the app:

但我有一个错误:

Error:(79, 37) error: cannot find symbol class DeshFalView

在上面突出显示的行中..

先谢谢你……

推荐答案

Problem :我做了一个stupid mistake我从forgotapply kotlin-android plugin

app gradle文件粘贴上方的Solution ::

apply plugin: 'kotlin-android'

Kotlin相关问答推荐

来自SnapshotFlow的单元测试StateFlow仅发出initialValue

用vararg替换列表的设计弃用警告

在Kotlin中的嵌套when语句中,else块是强制性的吗?

Kotlin 复制列表中的项目以创建具有相同数据的不同对象的新列表

使用 Kotlin 的 Springboot 中缺少 ResponseEntity 正文属性

Kotlin 接口类型参数

按钮无法在 Android Studio 上打开新活动

如何使用函数类型或 lambdas 作为 Kotlin 上下文接收器的类型?

为什么 Kotlin 的 null 安全性不能与局部变量初始化器一起正常工作?

如何在 Compose 中创建可重用的修饰符?

具有多个不同类型来源的 LiveData

runBlocking 中的 deferred.await() 抛出的异常即使在被捕获后也被视为未处理

Kotlin 有 array.indexOf 但我无法弄清楚如何做 array.indexOfBy { lambda }

Kotlin:如何在活页夹中返回正在运行的服务实例?

哪里可以找到aapt2日志(log)?

Kotlin的web-framework框架

从片段(fragment)中的点击事件启动协同程序

在Kotlin中为Android编写库会有开销吗?

Kotlin lambda 语法混淆

Kotlin for assertThat(foo, instanceOf(Bar.class))