VaibhavMojidra / Android-Jetpack-Compose---Demo-TextField

Android Jetpack Compose provides the TextField component, which is a flexible and customizable text input field for building user interfaces in Android apps. The TextField in Jetpack Compose offers a more declarative and composable approach compared to traditional Android EditText views.
https://vaibhavmojidra.github.io/site/
MIT License
0 stars 0 forks source link

Question in regards to how you implemented `TextField` #1

Closed BBBmau closed 10 months ago

BBBmau commented 10 months ago

Hi!

I am fairly new to android development however I have been programming for quite a while now so certain concepts don't take too long to grasp. One issue I've encountered which seems like such a minor issue that I can't seem to fix is being able to add TextField into my project.

I run into the issue of being able to use the it argument in onValueChange where it has me wanting to create a local variable which makes ZERO sense.

It could be my setup for the project but this is a brand new android studio project and it's very frustrating that something as simple as adding a TextField is taking forever to implement. Let me know what your process was it would help a ton.

For context this is what my IDE shows when attempting to add a TextField:

image

I've attempted to follow several tutorials as well with no results from them: https://developer.android.com/jetpack/compose/text/user-input

BBBmau commented 10 months ago

Found the issue, looks like it was a dependency issue in gradle.app.

I ended up creating a new project to compare both dependencies:

Old:

dependencies {

    implementation 'androidx.core:core-ktx:1.12.0'
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
    implementation 'androidx.activity:activity-compose:1.8.2'
    implementation platform('androidx.compose:compose-bom:2022.10.00')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

New:

dependencies {

    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("androidx.activity:activity-compose:1.8.2")
    implementation(platform("androidx.compose:compose-bom:2023.08.00"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-graphics")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.material3:material3")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
    androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")
}