• Latest Code...

    Featured Post

    Implementing Hilt in a Kotlin Android Jetpack Compose Project with MVVM Architecture

     In modern Android development, maintaining a scalable codebase can be challenging, especially when it comes to dependency management. Hilt,...

    How to access child views from a ListView in android

    Are you get lots problems during access child view from a listview in android, then here is the some solution that may helpful for you.



    Android ListView: get data index of visible itemand combine with part of Feet's answer above, can give you something like:

    int wantedPosition = 10; // Whatever position you're looking for
    int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount(); // This is the same as child #0
    int wantedChild = wantedPosition - firstPosition;
    // Say, first visible position is 8, you want position 10, wantedChild will now be 2
    // So that means your view is child #2 in the ViewGroup:
    if (wantedChild < 0 || wantedChild >= listView.getChildCount()) {
    Log.w(TAG, "Unable to get view for desired position, because it's not being displayed on screen.");
    return;
    }
    // Could also check if wantedPosition is between listView.getFirstVisiblePosition() and listView.getLastVisiblePosition() instead.
    View wantedView = listView.getChildAt(wantedChild);

    this solution copy from stackoverflow and i solved my solution from this:

    Happy Coding!!!

    Contact Form

    Name

    Email *

    Message *