本文介绍了Adobe Flex Mobile - TextArea 拒绝在 Android 上滚动,StageWebView 根本不会滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 Spark TextArea 组件在添加文本时自动向下滚动.

I'm trying to make the Spark TextArea component automatically scroll down as text is added to it.

首次填充 TextArea 时,垂直滚动条位于底部.但是如果我附加更多文本,它就完全拒绝滚动.它适用于 iOS 平台,但不适用于 Android!

When the TextArea is first populated, the vertical scrollbar is at the bottom. But if I append more text, it just outright refuses to scroll. Its working on the iOS platform, but it won't on Android!!

根据此处找到的示例,我尝试执行以下操作:http://devgirl.org/2010/12/16/automatically-scroll-flex-mobile-textarea/

I've tried doing the following, according to the example found here: http://devgirl.org/2010/12/16/automatically-scroll-flex-mobile-textarea/

StyleableTextField(TextArea1.textDisplay).htmlText += textHTML;
StyleableTextField(TextArea1.textDisplay).scrollV++;

我也试过以下两行代码:

I've also tried the following two lines of code:

StyleableTextField(TextArea1.textDisplay).verticalScrollPosition = int.MAX_VALUE - 1;
TextArea1.scrollToRange(int.MAX_VALUE, int.MAX_VALUE);

没有任何效果!每当 TextArea 更新时,它只会向上滚动到顶部,或者根本不移动.

NOTHING WORKS! Whenever the TextArea is updated, it just scrolls back up to the top, or doesn't move at all.

我什至尝试更改程序,以便将 HTML 内容显示在 StageWebView 中.但是我根本无法让那个滚动,即使在 iPad 上也是如此.我尝试调用一个 JavaScript 函数 (document.getElementById('id').focus()) 以及在代码中插入一个隐藏的锚标记,并在其上调用 loadURL().两种解决方案都不起作用.

I even tried changing the program so that the HTML content is displayed in a StageWebView instead. But I can't get that one to scroll at all, even on the iPad. I tried calling a JavaScript function (document.getElementById('id').focus()) as well as inserting a hidden anchor tag into the code, and calling loadURL() on it. Neither solution worked.

有人可以帮我解决这个问题吗?我完全被难住了.

Can someone please help me out with this? I am absolutely stumped.

推荐答案

您可以使用默认文本字段,但请注意,当文本输入聚焦时,您必须处理诸如自动滚动到该文本字段之类的所有内容(因此,如果您将文本输入放置得太近)键盘的区域,它将被键盘覆盖),SoftKeyboardType 可能无法正确显示(如数字键盘)...在我看来,舞台文本是 textinput 的最佳选择.

You can use default textfield but be mindful that you have to handle everything like Autoscroll to that textfield when textinput is focused in (so if you place the textinput too close the area of the keyboard, it will be covered by the keyboard), SoftKeyboardType may not appear correctly (like Number keyboard)...From my point of view, stage text is the best possible option for textinput.

这是我的工作,使您的 StageText 文本输入按预期工作.

This is my work around to make your StageText textinput works as expected.

  1. 复制 StyleableStageText 的内容并新建一个类似 ExtendedStyleableStageText 的文件

  1. Copy the content of StyleableStageText and create a new file like ExtendedStyleableStageText

在 ExtendedStyleableStageText 中添加 2 个函数:

In ExtendedStyleableStageText add 2 functions:

公共函数 freezeStageText(){如果(舞台文本){如果(stageText.visible){createProxyImage();}stageText.visible = false;stageText.stage = null;}}

public function freezeStageText(){ if(stageText){ if(stageText.visible){ createProxyImage(); } stageText.visible = false; stageText.stage = null; }}

公共函数 unFreezeStageText():void{如果(舞台文本){if(!stageText.visible){disposeProxyImage();}stageText.visible = true;stageText.stage = 舞台;}
}

public function unFreezeStageText():void{if(stageText){ if(!stageText.visible){ disposeProxyImage(); } stageText.visible = true; stageText.stage = stage;}
}

将 spark.skins.mobile.supportClasses.StageTextSkinBase 的内容复制到像 ExtendedStageTextSkinBase 这样的新文件中.

Copy the content of spark.skins.mobile.supportClasses.StageTextSkinBase to a new file like ExtendedStageTextSkinBase.

复制 spark.skins.mobile.StageTextInputSkin 的内容并创建我们自己的文本输入皮肤文件.在你的皮肤中,皮肤类应该扩展你新创建的 ExtendedStageTextSkinBase 文件并添加函数

Copy the content of spark.skins.mobile.StageTextInputSkin and create your our own textinput skin file.In your skin, the skin class should extend your newly created ExtendedStageTextSkinBase file and add the function

    protected function commitCurrentState():void{
      super.commitCurrentState();
      if(currentState == 'disabled'){
         textDisplay.freezeStageText();
      }else{
         textDisplay.unFreezeStageText();
      }
    }

  • 在任何需要使用文本输入的视图中,如果您需要在视图顶部显示弹出窗口,请确保将所有启用的文本输入更改为 false,或者如果您需要定位文本滚动时正确,您可以将 TouchInteractionStart 和 TouchInteractionEnd 添加到滚动条然后监听事件,当用户开始触摸并滚动滚动条时,禁用视图中可见的所有文本输入,当用户停止触摸时,重新启用所有文本输入.

  • In any of your view that need to use the textinput, if you need to display a popup on top of the view, make sure to change all your textinput enabled to false, or if you need to position the text correctly when scrolling, you can add TouchInteractionStart and TouchInteractionEnd to the scroller then listen to the event, when user starts touching and scroll the scroller, disabled all the text input that are visible in the view and when user stops touching, re-enabled all the textinputs.

    希望这会有所帮助.

    这篇关于Adobe Flex Mobile - TextArea 拒绝在 Android 上滚动,StageWebView 根本不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 07-24 02:14