kotlin-android-extensions

How to Pass custom object via intent in kotlin

旧街凉风 提交于 2021-02-15 09:14:29
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

How to Pass custom object via intent in kotlin

浪子不回头ぞ 提交于 2021-02-15 09:09:34
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

How to Pass custom object via intent in kotlin

守給你的承諾、 提交于 2021-02-15 09:07:31
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

How to add Body in Url in Volley request in Kotlin?

浪尽此生 提交于 2021-02-09 11:32:16
问题 Here is my Code that for Volley Request:- val searchRequest = object : JsonArrayRequest(Request.Method.GET,url, Response.Listener { response -> val result = response.toString() }, Response.ErrorListener { error -> Toast.makeText(activity, "Error!",Toast.LENGTH_LONG) .show() Log.d("ERROR",error.toString()) }) { override fun getBody(): ByteArray { // TODO add Body, Header section works ////////// return super.getBody() } override fun getBodyContentType(): String { return "application/json" }

Kotlin DialogFragment editText editable always null

℡╲_俬逩灬. 提交于 2021-01-28 06:55:19
问题 So, I'm using Kotlin extensions which is straightforward, but I can't get string from edittext here is my code: override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val v = activity.layoutInflater .inflate(R.layout.dialog_group, null) v.add_group_button.setOnClickListener(addListener) return AlertDialog.Builder(activity) .setView(v) .create() } private var addListener: View.OnClickListener = View.OnClickListener { val groupNameInput: String = view?.group_edit_text?.text.toString

How to combine two different length lists in kotlin?

社会主义新天地 提交于 2020-12-10 00:39:51
问题 I want to combine two different length lists. For example; val list1 = listOf(1,2,3,4,5) val list2 = listOf("a","b","c") I want to result like this (1,"a",2,"b",3,"c",4,5) Is there any suggestion? 回答1: You may use the .zip function for that list1.zip(list2){ a,b -> listOf(a,b)}.flatten() The only problem is that it will only process elements, with both sets, so if (like in the example) let's have different size - it will not work The alternative could be to add specific markers and filter

How to combine two different length lists in kotlin?

ぐ巨炮叔叔 提交于 2020-12-10 00:37:37
问题 I want to combine two different length lists. For example; val list1 = listOf(1,2,3,4,5) val list2 = listOf("a","b","c") I want to result like this (1,"a",2,"b",3,"c",4,5) Is there any suggestion? 回答1: You may use the .zip function for that list1.zip(list2){ a,b -> listOf(a,b)}.flatten() The only problem is that it will only process elements, with both sets, so if (like in the example) let's have different size - it will not work The alternative could be to add specific markers and filter

How to combine two different length lists in kotlin?

£可爱£侵袭症+ 提交于 2020-12-10 00:33:11
问题 I want to combine two different length lists. For example; val list1 = listOf(1,2,3,4,5) val list2 = listOf("a","b","c") I want to result like this (1,"a",2,"b",3,"c",4,5) Is there any suggestion? 回答1: You may use the .zip function for that list1.zip(list2){ a,b -> listOf(a,b)}.flatten() The only problem is that it will only process elements, with both sets, so if (like in the example) let's have different size - it will not work The alternative could be to add specific markers and filter