java - 在 kotlin 中找不到类?

标签 java android kotlin classnotfoundexception classnotfound

 Intent intent=new Intent(MainActivity.this, ContactListActivity.class);
                        startActivity(intent);

MainActivity.this是用java编写的,ContactListActivity是用kotlin编写的。我试图调用 ContactListActivty 但最终收到错误

 have you declared this activity in your AndroidManifest.xml?

我还在 list 文件中添加了该 Activity 。

 <activity android:name="Chat_Activity$Connections$ContactListActivity"
            android:parentActivityName=".MainActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity"/>
        </activity>

编辑:

ContactListActivity.kt

class ContactListActivity : AppCompatActivity() {

    private var mBroadcastReceiver: BroadcastReceiver? = null
    private val TAG:String="ContactListActivity"

    //static variable
    object Obz{
        @JvmStatic val GetContactListFromServer:String="Contact List"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(layout.activity_contact_list)


        title = "Contact list"

        contact_list.hasFixedSize()
        contact_list.layoutManager= LinearLayoutManager(this)

        getContactListAndNextActivity()
    }

    fun getContactListAndNextActivity(){

        contact_list.adapter= ContactListAdaptor(applicationContext, dbHelper(applicationContext).getContactList())

    }

}

最佳答案

您的 list name条目看起来很可疑。

android:name="Chat_Activity$Connections$ContactListActivity"

我不确定完全限定的路径名​​是什么,但请尝试:

android:name=".ContactListActivity"

android:name="<qualified.path.to>.ContactListActivity"

关于java - 在 kotlin 中找不到类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43846596/

相关文章:

Java 类型级别注解和私有(private)成员可见性

swing - java中的"Events type"

java - Android 应用风格可在输出 APK 中包含某些文件

android - Android Kotlin-每分钟发送一次通知

android - 从 PlayStore 下载后不显示 Admob 广告

java - 在 Java 中获取 Windows 内核版本?

java - Java 框架是怎样构建的?

java - Android 1.5 和 1.6 中的 ListAdapter : are there any differences?

java - Android水平 ScrollView

android - 子回收器 View 的预取 View 不起作用