如何在ListView中的位置X處獲取視圖?我不想膨脹一個新的,只是檢索在屏幕上可見的單元格以編程方式更改一些參數在ListView的位置X處獲取視圖
0
A
回答
1
發現了一個骯髒的解決方案:
- 你應該能夠識別產生的每一行。例如添加與能見度一個TextView =消失,併產生當寫一個唯一值存在(或回收的行)
- 在listactivity調用getListView.setSelection(位置)到所需的細胞
調查列表視圖列表行(直至顯示)
lv=getListView(); for (int i=0;i <lv.getChildCount();i++){ if (((TextView)lv.findViewById(R.id.my_hidden_textview)).getText.equals(mykey)){ // view found } else { // schedule another survey "soon" } }
日程表,你可以使用類似:
final int RETRY_DELAY=100; new Handler(){ public void handleMessage(Message msg){ if (msg.what<0) return; //something went wrong and retries expired lv=getListView(); for (int i=0;i <lv.getChildCount();i++){ if (((TextView)lv.findViewById(R.id.my_hidden_textview)).getText.equals(mykey)){ //result = lv.findViewById(R.id.my_hidden_textview); } else { this.sendEmptyMessageDelayed(msg.what-1,RETRY_DELAY); } } } }.sendEmptyMessageDelayed(10,RETRY_DELAY);
正如我所說是一個非常醜陋的解決方案,但它的工作
2
由於ListView中的視圖重新使用/重新循環。沒有從ListView獲取視圖引用的直接方式。
如果要訪問視圖,您需要擴展ArrayAdapter
,然後覆蓋getView
。在那裏您應該撥打super.getView
並編寫您自己的自定義代碼。
如果我們確實需要控制更多的嘗試延伸BaseAdapter
或CursorAdapter
。
1
我沒有清楚地理解你的問題。但根據我的理解,我建議您在線性佈局內使用框架佈局。您可以使用其他框架佈局來進行操作。
相關問題
- 1. android listview獲取視圖的位置
- 2. 獲取視圖的位置
- 3. 在ListView中獲取位置
- 4. 在ListView中獲取絕對視圖位置
- 5. 地圖視圖獲取位置
- 6. Android獲取視圖在水平滾動視圖中的位置
- 7. Android:在ListView中獲取位置長按
- 8. ListView中的視圖位置不一致
- 9. 如何獲取XYSeries x位置的屏幕x位置?
- 10. 如何從(X,Y)位置獲取ListView項目?
- 11. 獲取ListView中項目的位置?
- 12. 從ListView中的項目獲取位置
- 13. 獲取位置選擇樹型視圖
- 14. 如何從視圖中獲取位置?
- 15. Android listview在滾動時獲取大多數中心視圖位置
- 16. 在Google地圖中獲取(x,y)中的標記位置
- 17. 超視圖旋轉後獲取子視圖的位置
- 18. 獲取ListView中的某個視圖
- 19. 如何獲取ListView項目的視圖?
- 20. WPF:如何獲取ListView Item中圖像的位置?
- 21. 主幹替換視圖/獲取視圖位置
- 22. 如何獲取WPF DataGridCell視覺水平(X軸)位置?
- 23. 使用UIScrollview時獲取x,y位置
- 24. 如何在android中放大後獲取視圖的xy位置
- 25. 如何獲取在LinearLayout上動態添加視圖的位置
- 26. 如何在座標中獲取視圖的位置?
- 27. 如何在列表視圖中獲取列表項的位置?
- 28. 按鈕onClick在視圖模式列表視圖中獲取錯誤的位置
- 29. 在特定位置的位置視圖?
- 30. 如何獲取複雜ListView行視圖中的視圖?
您正在使用哪個適配器? – havexz
ArrayListAdapter – Addev