Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.NoSuchElementException;
import android.widget.Adapter;

public class Main {
    public static final int getAdapterPositionById(final Adapter adapter, final long id)
            throws NoSuchElementException {
        final int count = adapter.getCount();

        for (int pos = 0; pos < count; pos++) {
            if (id == adapter.getItemId(pos)) {
                return pos;
            }
        }

        throw new NoSuchElementException();
    }
}