大约有 366 项符合查询结果(耗时:0.0381秒) [XML]
How to use the same C++ code for Android and iOS?
...hared code is in this segment. The highest level is regular Obj-C / Java / Kotlin code, no news here, the hard part is the middle layer.
The middle layer to iOS side is simple; you only need to configure your project to build using a variant of Obj-c know as Objective-C++ and it is all, you have ac...
How enable auto-format code for Intellij IDEA?
...
Smart, but not for Kotlin
– jobbert
Aug 9 '18 at 9:02
add a comment
|
...
How to resize a custom view programmatically?
...
In Kotlin, you can use the ktx extensions:
yourView.updateLayoutParams {
height = <YOUR_HEIGHT>
}
share
|
improve t...
when I run mockito test occurs WrongTypeOfReturnValue Exception
...
Thanks, It looks like there is the same issue with Kotlin data classes as fields, and your solution solved it!
– Mohsen Mirhoseini
Aug 15 '18 at 17:56
...
Android add placeholder text to EditText
...TextView
((TextView) findViewById(R.id.email)).setText("your Text")
In Kotlin:
// Cast your EditText into a TextView
// Like this
(findViewById(R.id.email) as TextView).text = "Your Text"
// Or simply like this
findViewById<TextView>(R.id.email).text = "Your Text"
...
Add & delete view from Layout
...
// Remove TextView from LinearLayout
linearLayout.removeView(textView);
kotlin:
// Root Layout
val linearLayout = LinearLayout(context)
linearLayout.gravity = Gravity.CENTER
linearLayout.orientation = LinearLayout.VERTICAL
// TextView
val textView = TextView(context)
textView.text = "Sample"
/...
How to set delay in android?
...
Handler answer in Kotlin :
1 - Create a top-level function inside a file (for example a file that contains all your top-level functions) :
fun delayFunction(function: ()-> Unit, delay: Long) {
Handler().postDelayed(function, delay)
}
...
OnCreateOptionsMenu() not called in Fragment
.... Thank you for sharing this! I had this exact problem because I'm using Kotlin and many times you don't have to do findViewById, etc... to get the view you need.
– DWndrer
Sep 16 '18 at 2:54
...
Android dismiss keyboard
...
Here's a Kotlin solution (mixing the various answers in thread)
Create an extension function (perhaps in a common ViewHelpers class)
fun Activity.dismissKeyboard() {
val inputMethodManager = getSystemService( Context.INPUT_METHO...
How to disable an Android button?
...
In Kotlin, if you refer the Button View with id then, enable/disable button as like
layout.xml
<Button
android:id="@+id/btn_start"
android:layout_width="100dp"
android:layout_height="50dp"
android:text="@stri...