Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在执行KeyEvent.KEYCODE_DPAD_UP,因此 GridView 中的一项获得焦点。我的要求是获取该项目的 ID(或位置)。有可能得到它吗?任何帮助或指导将不胜感激。
我使用gridView.setOnItemSelectedListener获得了焦点项目的位置。
gridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { int mPosition = pos; } });