大约有 850 项符合查询结果(耗时:0.0208秒) [XML]
Android webview launches browser when calling loadurl
...
myWebView.webViewClient = WebViewClient() in Kotlin!
– Thomas Pritchard
Apr 24 '18 at 12:32
add a comment
|
...
How to check if APK is signed or “debug build”?
... ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
Kotlin:
val isDebuggable = 0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE
For more information, please see Securing Android LVL Applications.
Alternatively, if you're using Gradle correctly, you can check ...
Implicit “Submit” after hitting Done on the keyboard at the last EditText
...
Simple and effective solution with Kotlin
Extend EditText:
fun EditText.onSubmit(func: () -> Unit) {
setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
func()
}
true
}
...
How do we use runOnUiThread in Android?
...k method runs in UI thread so don't need to use runOnUiThread here.
Using Kotlin
While in Activity,
this.runOnUiThread {
// Do stuff
}
From Fragment,
activity?.runOnUiThread {
// Do stuff
}
Using Java,
this.runOnUiThread(new Runnable() {
void run() {
// Do stuff
...
Reflection generic get field value
...
I post my solution in Kotlin, but it can work with java objects as well.
I create a function extension so any object can use this function.
fun Any.iterateOverComponents() {
val fields = this.javaClass.declaredFields
fields.forEachIndexed { i, ...
How to call a method after a delay in Android
...
Kotlin
Handler(Looper.getMainLooper()).postDelayed({
//Do something after 100ms
}, 100)
Java
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Ove...
How to pass a view's onClick event to its parent on Android?
...y the proper pressed states (e.g., ripple effect). This answer is also in Kotlin instead of Java.
view.setOnTouchListener { view, motionEvent ->
(view.parent as View).onTouchEvent(motionEvent)
}
share
|
...
Android get current Locale, not default
...rationCompat.getLocales(getResources().getConfiguration()).get(0);
or in Kotlin:
val currentLocale = ConfigurationCompat.getLocales(resources.configuration)[0]
share
|
improve this answer
...
Set android shape color programmatically
...uestion was answered a while back, but it can modernized by rewriting as a kotlin extension function.
fun Drawable.overrideColor(@ColorInt colorInt: Int) {
when (this) {
is GradientDrawable -> setColor(colorInt)
is ShapeDrawable -> paint.color = colorInt
is ColorD...
How can you tell when a layout has been drawn?
...
Better with kotlin extension functions
inline fun View.waitForLayout(crossinline yourAction: () -> Unit) {
val vto = viewTreeObserver
vto.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
ov...