kotlin-android-extensions

Unable to get data from sqlite database

你。 提交于 2019-12-20 05:50:13
问题 The problem is that when I run my code the app is stopping with an error (java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twixt.pranav.pos/com.twixt.pranav.pos.View.Activity.Cart}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.content.Context.getDatabasePath(java.lang.String)' on a null object reference) in the code you could see that I have inserted one data manually I have seen similar questions but no solutions for it This is

Experimental features in Android extension is good for Production release

可紊 提交于 2019-12-20 01:41:54
问题 I'm using the @Parcelize feature in android development using Kotlin language. To use them I have done the below modifications in build.gradle file. apply plugin: 'kotlin-android-extensions' then androidExtensions { experimental = true } I'm successful in using the above feature. But is it recommended to use them for production release or only for development purpose alone? 回答1: This isn't just an Android-thing though, it's Kotlin in general. Kotlin has quite a few experimental features, such

Kotlin custom dialog Parameter specified as non-null

本秂侑毒 提交于 2019-12-19 12:40:51
问题 I got this error : Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState When i am trying to inflate a custom dialog in Kotlin , i got the error i wrote above on the super.onCreate line in the dialog. the dialog code is : class Custom_Dialog_Exit_App(var activity: Activity)// TODO Auto-generated constructor stub : Dialog(activity, R.style.full_screen_dialog) { override

Out-projected type 'ArrayList<*>' prohibits the use of 'public open fun add(index: Int, element: E): Unit defined in java.util.ArrayList'

感情迁移 提交于 2019-12-18 14:06:43
问题 I have this snippets: class RecyclerViewAdapter internal constructor( val clazz: Class<out RecyclerViewViewHolder>, val layout: Int, var dataList: MutableList<*>) ... ... ... fun RecyclerView.getDataList() : ArrayList<*> { return (adapter as RecyclerViewAdapter).dataList as ArrayList<*> } ... ... ... then I use that on this: recyclerView.getDataList().add(Person("Lem Adane", "41 years old", 0)) but I get this error: Error:(19, 31) Out-projected type 'ArrayList<*>' prohibits the use of 'public

Unresolved reference for synthetic view when layout is in library module

蓝咒 提交于 2019-12-18 10:20:43
问题 using Kotlin 1.20.20 (not that it matters, older versions behaves the same) When layout is in separate library module Android Studio has no problem finding and referencing the view import kotlinx.android.synthetic.main.view_user_input.* But when I try to compile app it fails with Unresolved reference: view_user_input on :app:compileDebugKotlin . Everything works fine when view is referenced IN the library module. Am I missing something here? Adding project structure. All modules are using

Deep copy of list with objects in Kotlin

允我心安 提交于 2019-12-18 07:45:03
问题 I am new to kotlin and I am trying to make a copy of a list of objects.The problem I am having is that when I change items in the new copy, the old list gets changed as well. This is the object: class ClassA(var title: String?, var list: ArrayList<ClassB>, var selected: Boolean) class ClassB(val id: Int, val name: String) I tried doing this, but it doesn't work: val oldList:ArrayList<ClassA> val newList :ArrayList<ClassA> = ArrayList() newList.addAll(oldList) 回答1: That's bacause you are

Kotlin synthetic in Adapter or ViewHolder

℡╲_俬逩灬. 提交于 2019-12-17 23:22:30
问题 I am new in kotlin. I have found and tried to use synthetic method instead of annoying method findViewById in my Activity class, but I have found "If we want to call the synthetic properties on View (useful in adapter classes), we should also import kotlinx.android.synthetic.main.view.*." But I can't figure out how it exactly works? Is there any examples? 回答1: Simple example from https://github.com/antoniolg/Kotlin-for-Android-Developers import kotlinx.android.synthetic.item_forecast.view.*

Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension

一笑奈何 提交于 2019-12-17 23:18:03
问题 I'm trying to figure out the best way to do Android View Binding in Kotlin. It seems like there are a few of options out there: findViewById val button: Button by lazy { findViewById<Button>(R.id.button) } Butterknife https://github.com/JakeWharton/butterknife @BindView(R.id.button) lateinit var button: Button Kotlin Android Extensions https://kotlinlang.org/docs/tutorials/android-plugin.html import kotlinx.android.synthetic.main.activity_main.* I'm pretty familiar with findViewById and

Identity equality for arguments of types Int and Int is deprecated

蓝咒 提交于 2019-12-14 00:46:12
问题 Just fyi, this is my first question on StackOverflow and I'm really new in Kotlin. While working on a project that's fully Kotlin (ver 1.1.3-2), I see a warning on the following code (with the comments for you curious lads): // Code below is to handle presses of Volume up or Volume down. // Without this, after pressing volume buttons, the navigation bar will // show up and won't hide val decorView = window.decorView decorView .setOnSystemUiVisibilityChangeListener { visibility -> if

Why is setting onClickListener working once?

早过忘川 提交于 2019-12-13 10:40:25
问题 I want to migrate a very solid project structure that I use to Kotlin. I first tried the basics: Activities and Fragment transactions. It appears so easy and simple: class MainActivity : AppCompatActivity(), SomeInterface { override fun onCreate(savedInstanceState: Bundle?) { setContentView(R.layout.activity_main) val mainFragment = supportFragmentManager.findFragmentById(R.id.fragment_main) as MainActionsFragment? ?: MainActionsFragment.newInstance() supportFragmentManager.inTransaction {