'How can I get the thread name (not lable)
How can I get the Thread Controller Name (i.e. 'Thread Group')?
In my test I have: Thread Controller Name: 'Thread Group' Thread Name: 'My Thread'
Thanks,
Solution 1:[1]
Take a look at the following JMeter Functions:
__threadGroupName()- returns the name of the Thread Group__threadNum()- returns the number of the current thread
Solution 2:[2]
So essentially you do not want the default value to display in the TextField. If the default value is -1 in this case, the following should work:
TextField(
value = if (npcID == -1) "" else npcId.toString(),
onValueChange = { npcId = it.toInt() },
label = { Text("Npc id") },
enabled = true
)
Solution 3:[3]
I succeded with this way.It is here source code:
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.platform.LocalTextInputService
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import kotlinx.coroutines.delay
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MainScreen()
}
}
}
@Composable
fun MainScreen() {
Surface(
modifier = Modifier.fillMaxSize()
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
AutoFocusingText()
}
}
}
@Composable
fun AutoFocusingText() {
val focusRequester = remember { FocusRequester() }
val inputService = LocalTextInputService.current
val focus = remember { mutableStateOf(true) }
val text = remember { mutableStateOf("-1")}
TextField(
value = if (text.value == "-1") "" else text.value,
onValueChange = {
text.value = it
},
label = { Text("Npc id") },
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Number),
modifier = Modifier
.focusRequester(focusRequester)
.onFocusChanged {
if (focus.value != it.isFocused) {
focus.value = it.isFocused
if (!it.isFocused) {
inputService?.hideSoftwareKeyboard()
}
}
}
)
LaunchedEffect(true) {
delay(100)
inputService?.showSoftwareKeyboard()
focusRequester.requestFocus()
}
}
@ExperimentalComposeUiApi
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
MainScreen()
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dmitri T |
| Solution 2 | Lyle February |
| Solution 3 | tugrul altun |

