首先,我想向您保證我已經閱讀了大量類似的帖子,因此我的問題還沒有找到答案。VIew onMeasure無限循環未採取任何行動
所以,問題(或我應該說的問題): 我有一個列表視圖與相當棘手的項目與文本視圖,按鈕,編輯文本里面。所有這些項目都是動態生成的。是的,我有最糟糕和最buggiest(有這樣的詞?)的東西,你可以想象在Android的發展。所以,爲了控制所有這些混亂,我有地獄機器,它包含關於焦點的所有信息,編輯文本中的光標位置以及其他很酷的東西。這真的是一大堆代碼,我相信你們中沒有人想看到它,也是絕密(開玩笑)。
所以,問題。當我點擊編輯文本在其中輸入smth時,我的Adapter的方法getView()開始無休止地被調用大約200次(即在一個循環中)。雖然它不會影響文本輸入或其他內容,但這完全不正常。在調試時,我看到onMeasure()方法最終調用了我的getView(),然後(出於某種原因)進入循環。
所以我的問題是:這怎麼可能,onMeasure進入一個循環?我只是點擊編輯文本,沒有別的,我沒有輸入任何數據,我不滾動我的列表,我甚至沒有觸摸我的手機,它不會自動移動。
我覺得自己很糟糕,因爲沒有給你我所有的代碼,所以至少我會給你onMeasure()方法的堆棧跟蹤。
StaticLayout(Layout).getWidth() line: 537
TextView.onMeasure(int, int) line: 6188
TextView(View).measure(int, int) line: 15172
LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4816
LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 1390
LinearLayout.measureHorizontal(int, int) line: 1038
LinearLayout.onMeasure(int, int) line: 576
LinearLayout(View).measure(int, int) line: 15172
HorizontalScrollView.measureChildWithMargins(View, int, int, int, int) line: 1216
HorizontalScrollView(FrameLayout).onMeasure(int, int) line: 310
HorizontalScrollView.onMeasure(int, int) line: 299
HorizontalScrollView(View).measure(int, int) line: 15172
RelativeLayout.measureChildHorizontal(View, RelativeLayout$LayoutParams, int, int) line: 617
RelativeLayout.onMeasure(int, int) line: 399
RelativeLayout(View).measure(int, int) line: 15172
FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4816
FrameLayout.onMeasure(int, int) line: 310
FrameLayout(View).measure(int, int) line: 15172
LinearLayout.measureVertical(int, int) line: 833
LinearLayout.onMeasure(int, int) line: 574
LinearLayout(View).measure(int, int) line: 15172
PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4816
PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 310
PhoneWindow$DecorView.onMeasure(int, int) line: 2220
PhoneWindow$DecorView(View).measure(int, int) line: 15172
ViewRootImpl.performMeasure(int, int) line: 1850
ViewRootImpl.measureHierarchy(View, WindowManager$LayoutParams, Resources, int, int) line: 1102
ViewRootImpl.performTraversals() line: 1275
ViewRootImpl.doTraversal() line: 1000
ViewRootImpl$TraversalRunnable.run() line: 4214
Choreographer$CallbackRecord.run(long) line: 725
Choreographer.doCallbacks(int, long) line: 555
Choreographer.doFrame(long, int) line: 525
Choreographer$FrameDisplayEventReceiver.run() line: 711
Handler.handleCallback(Message) line: 615
Choreographer$FrameHandler(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 137
ActivityThread.main(String[]) line: 4787
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 511
ZygoteInit$MethodAndArgsCaller.run() line: 789
ZygoteInit.main(String[]) line: 556
NativeStart.main(String[]) line: not available [native method]