在运行Android 4.0(Ice Cream Sandwich)的Android模拟器上测试时,我注意到Edittext做了一些非常奇怪的事情.
首先,它强调了用红色标识为"拼写错误"的每个单词.如何禁用此功能?其次,尽管在布局XML中我指定了android:scrollHorizontally="true"自动换行:如何禁用它?以下是Edittext的Layout XML代码:
<EditText
android:id="@+id/editor"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/toolbar"
android:layout_toRightOf="@+id/toolbarleft"
android:paddingBottom="0dp"
android:paddingRight="0dp"
android:scrollHorizontally="true"
android:text=""
android:inputType="textMultiLine" >
<requestFocus />
</Edittext>
Run Code Online (Sandbox Code Playgroud)
以下是我需要禁用的拼写检查器的示例:
拼写检查器的演示http://www.abstract-thoughts.com/wp-content/uploads/2011/10/spell.jpg
非常感谢!
android spell-checking word-wrap android-edittext android-4.0-ice-cream-sandwich
我试图通过调用来获取EditText以清除其跨度EditText.getText().clearSpans().但是,如果我调用此方法,EditText开始表现奇怪,换行显示为框,然后我设置的任何跨度都在完全错误的位置.
所以我的问题是:如何清除和EditText的跨度?(不调用setText() - 文本可能长达数千行,而且它太慢而不能经常重绘它)
非常感谢!
我遇到了一个看似非常简单的问题 - 我希望每次用户(或程序)向上或向下滚动EditText时运行代码,就像TextChanged监听器允许您每次用户或程序运行代码一样改变文字.这可能吗?谢谢!
我知道char不能包含Unicode字符(比如char c ='\ u1023').那我该怎么做呢
String s = "ABCDEFG\u1023";
char[] c = s.toCharArray();
Run Code Online (Sandbox Code Playgroud)
出于性能原因,我想将s转换为CharArray,因为我必须循环遍历可能非常长的字符串中的每个字符,这是低效的.任何达到相同结果的东西都很好.
非常感谢!
编辑:实际上char可以包含unicode字符.我只是傻了.感谢那些帮助过的人.
在使用jTidy(在Android上)时,我遇到了一个非常烦人的问题.我发现jTidy适用于我测试过的每个HTML文档,除了以下内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- Always force latest IE rendering engine & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>templates</title>
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
</head>
<body>
<div>
<header>
<h1>Page Heading</h1>
</header>
<nav>
<p><a href="/">Home</a></p> …Run Code Online (Sandbox Code Playgroud) 在edittext中有一种获取光标当前行的方法吗?如果不是,我会写自己的方法,但只是想检查.如果我编写自己的方法,最好的方法是遍历edittext中的每个字符,直到selectionstart并使用For循环计算\n的数量,或者有更好的方法吗?谢谢!
我想知道是否可以将方法的参数设置为Object,它必须是一个扩展的类并实现另一个类.这是一个例子:假设我有一个名为ClassA的类和一个名为MyInterface的接口.
public class ClassA {
/* code */
}
public interface MyInterface {
/* code */
}
Run Code Online (Sandbox Code Playgroud)
让我们说其他地方有一个名为ClassB的类,它们都扩展了ClassA并实现了MyInterface.
public class ClassB extends ClassA implements MyInterface {
/* code */
}
Run Code Online (Sandbox Code Playgroud)
我也可以有一个ClassC,它还扩展了ClassA并实现了MyInterface:
public class ClassC extends ClassA implements MyInterface {
/* code */
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:
假设我有一个名为method1的方法,在method1中我希望有一个接受Object的参数.假设我希望这个Object要么是ClassA的子类,要么实际上是ClassA本身.这很容易做到:
public void method1(ClassA parameter) {
}
Run Code Online (Sandbox Code Playgroud)
假设我也想要一个方法2,并且在方法2中我想要一个接受任何实现MyInterface的参数的参数.同样,这很容易:
public void method2(MyInterface parameter) {
}
Run Code Online (Sandbox Code Playgroud)
但是如果我想要一个method3,并且我希望有一个参数只接受ClassA的子类或ClassA本身,并且实现MyInterface,那么接受ClassB和ClassC,但不接受任何只扩展ClassA的类,或者只实现MyInterface,或者两者都不实现.喜欢:
public void method3 ([Something that extends ClassA implements MyInterface] parameter) {
/* code */
}
Run Code Online (Sandbox Code Playgroud)