這是我的頭適配器問題getTag(),返回null
public class MyAdapter extends ResourceCursorAdapter implements OnScrollListener {
在我的適配器我設置的標籤這樣
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final View view = super.newView(context, cursor, parent);
final MyCache cache = new MyCache();
view.setTag(cache);
}
比我有一些方法
public void metA(){
//here I want to read the tag
//how can I do that ?
}
我也是圖案滾動式收聽器
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//how to read for example the third item in the list ?
//item.getTag() returns null
}
我用getItem(0)嘗試過,但我也收到空指針異常... 什麼是正確的方式來讀取onScroll方法中的標記,視圖實際上包含什麼? 我知道我做的事很愚蠢,但我無法想象。
我可以看到適配器的整個來源嗎? – Alex
它太大了,但它自己的適配器不是問題。我的問題是如何在newView方法中設置witT setTag()的視圖的標記(getTag())。我的問題是如何閱讀標籤? – Lukap