Android EditText文本长度不受限制

时间:2012-01-19 15:26:44

标签: android text android-edittext max

当android:maxLength和android:maxLines未设置时,可滚动多行EditText中是否存在设备特定限制(除了总可用内存大小)到文本长度或行数?我有一个EditText:

<EditText
  android:editable="false"
  android:id="@+id/sip_log_log"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_weight = "1"
  android:text=""
  android:gravity = "top"
  android:textColor="#00FF00"
  android:background="#000000"
  android:scrollbars="vertical"
  android:focusable="true"
  />

当我打电话

mEditText.setText("some very very loooong string....");

仅显示文本的第一部分。问题是特定于设备。一切都适用于HTC Sensation或模拟器,但三星Galaxy S 2从未显示超过20页的文本。我能以某种方式修复它吗?或者是否有另一种方法可以在滚动条的其他标准视图中显示极长文本(我们的SIP客户端中的SIP日志)?

感谢所有回复。

4 个答案:

答案 0 :(得分:2)

将android:maxLength =“99999999”添加到您的布局文件中会修复此问题!

答案 1 :(得分:1)

我测试了WebView,即使使用长文本也能很好地工作,但我仍然想知道为什么Samsung Galaxy上的EditText无法正常工作。

答案 2 :(得分:1)

我遇到了同样的问题,在XML中设置android:maxLength="999999并没有解决这个问题。但是以编程方式设置长度过滤器的工作原理如下:

    EditText mPrimaryPhoneField = (EditText) findViewById(R.id.primary_phone);
    InputFilter[] phoneFilterArray = new InputFilter[1];
    //This needs to be a large number to fix a bug on Samsung Galaxy tablet where it would have a default limitation on numeric fields if you had no length filter at all.
    phoneFilterArray[0] = new InputFilter.LengthFilter(100);
    mPrimaryPhoneField.setFilters(phoneFilterArray);

答案 3 :(得分:0)

完全删除public class FluentWaitDemo { public static void main(String[] args) throws InterruptedException { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://app.hubspot.com/login"); By email = By.xpath("//input[@type='email']"); WebElement userId = FluentWaitForElement(driver, email); userId.sendKeys("*******@gmail.com"); driver.close(); } public static WebElement FluentWaitForElement(WebDriver driver, By locator) { Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(Duration.ofSeconds(10)) .pollingEvery(Duration.ofSeconds(2)) .ignoring(NoSuchElementException.class); return wait.until(ExpectedConditions.presenceOfElementLocated(locator)); } } 属性并将Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@type='email']"} (Session info: chrome=83.0.4103.97) For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html 添加到布局文件为我修复了该问题。

相关问题