• Latest Code...

    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.");
    // 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!!!

    No comments:

    Post a Comment


    Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace