在我的机器人Activity
中,我需要添加两个EditText
,一个用于标题,另一个用于描述。
当我编辑第一个EditText
(标题)时没关系,但当我尝试编辑第二个EditText
(描述)时,它会编写奇怪的字符,当我触摸我的活动中的任何地方时一个例外。
我尝试创建新的Activity
并添加EditText
,但我仍然遇到同样的问题。
堆栈跟踪:
E/InputEventReceiver(10790): Exception dispatching input event.
E/MessageQueue-JNI(10790): Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI(10790): java.lang.IndexOutOfBoundsException
E/MessageQueue-JNI(10790): at android.graphics.Paint.getTextRunAdvances(Paint.java:2256)
E/MessageQueue-JNI(10790): at android.text.TextLine.handleText(TextLine.java:815)
E/MessageQueue-JNI(10790): at android.text.TextLine.handleRun(TextLine.java:970)
E/MessageQueue-JNI(10790): at android.text.TextLine.measureRun(TextLine.java:483)
E/MessageQueue-JNI(10790): at android.text.TextLine.measure(TextLine.java:362)
E/MessageQueue-JNI(10790): at android.text.Layout.getHorizontal(Layout.java:856)
E/MessageQueue-JNI(10790): at android.text.Layout.getHorizontal(Layout.java:834)
E/MessageQueue-JNI(10790): at android.text.Layout.getPrimaryHorizontal(Layout.java:809)
E/MessageQueue-JNI(10790): at android.text.Layout.getPrimaryHorizontal(Layout.java:799)
E/MessageQueue-JNI(10790): at android.widget.TextView.getFocusedRect(TextView.java:6468)
E/MessageQueue-JNI(10790): at android.view.FocusFinder.findNextFocusInAbsoluteDirection(FocusFinder.java:245)
E/MessageQueue-JNI(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:166)
E/MessageQueue-JNI(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:97)
E/MessageQueue-JNI(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:68)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:726)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/MessageQueue-JNI(10790): at android.view.View.focusSearch(View.java:7738)
E/MessageQueue-JNI(10790): at android.widget.TextView.onCreateInputConnection(TextView.java:7092)
E/MessageQueue-JNI(10790): at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1346)
E/MessageQueue-JNI(10790): at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1518)
E/MessageQueue-JNI(10790): at android.view.inputmethod.InputMethodManager.viewClicked(InputMethodManager.java:1694)
E/MessageQueue-JNI(10790): at android.widget.TextView.viewClicked(TextView.java:11081)
E/MessageQueue-JNI(10790): at android.widget.TextView.onTouchEvent(TextView.java:9588)
E/MessageQueue-JNI(10790): at android.view.View.dispatchTouchEvent(View.java:8981)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.widget.ScrollView.dispatchTouchEvent(ScrollView.java:615)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/MessageQueue-JNI(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/MessageQueue-JNI(10790): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2568)
E/MessageQueue-JNI(10790): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1776)
E/MessageQueue-JNI(10790): at android.app.Activity.dispatchTouchEvent(Activity.java:2866)
E/MessageQueue-JNI(10790): at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
E/MessageQueue-JNI(10790): at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
E/MessageQueue-JNI(10790): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2529)
E/MessageQueue-JNI(10790): at android.view.View.dispatchPointerEvent(View.java:9186)
E/MessageQueue-JNI(10790): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4706)
E/MessageQueue-JNI(10790): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4544)
E/MessageQueue-JNI(10790): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.
E/AndroidRuntime(10790): FATAL EXCEPTION: main
E/AndroidRuntime(10790): Process: com.bitdyne.jamaati.ui.activities, PID: 10790
E/AndroidRuntime(10790): java.lang.IndexOutOfBoundsException
E/AndroidRuntime(10790): at android.graphics.Paint.getTextRunAdvances(Paint.java:2256)
E/AndroidRuntime(10790): at android.text.TextLine.handleText(TextLine.java:815)
E/AndroidRuntime(10790): at android.text.TextLine.handleRun(TextLine.java:970)
E/AndroidRuntime(10790): at android.text.TextLine.measureRun(TextLine.java:483)
E/AndroidRuntime(10790): at android.text.TextLine.measure(TextLine.java:362)
E/AndroidRuntime(10790): at android.text.Layout.getHorizontal(Layout.java:856)
E/AndroidRuntime(10790): at android.text.Layout.getHorizontal(Layout.java:834)
E/AndroidRuntime(10790): at android.text.Layout.getPrimaryHorizontal(Layout.java:809)
E/AndroidRuntime(10790): at android.text.Layout.getPrimaryHorizontal(Layout.java:799)
E/AndroidRuntime(10790): at android.widget.TextView.getFocusedRect(TextView.java:6468)
E/AndroidRuntime(10790): at android.view.FocusFinder.findNextFocusInAbsoluteDirection(FocusFinder.java:245)
E/AndroidRuntime(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:166)
E/AndroidRuntime(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:97)
E/AndroidRuntime(10790): at android.view.FocusFinder.findNextFocus(FocusFinder.java:68)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:726)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.ViewGroup.focusSearch(ViewGroup.java:728)
E/AndroidRuntime(10790): at android.view.View.focusSearch(View.java:7738)
E/AndroidRuntime(10790): at android.widget.TextView.onCreateInputConnection(TextView.java:7092)
E/AndroidRuntime(10790): at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1346)
E/AndroidRuntime(10790): at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1518)
E/AndroidRuntime(10790): at android.view.inputmethod.InputMethodManager.viewClicked(InputMethodManager.java:1694)
E/AndroidRuntime(10790): at android.widget.TextView.viewClicked(TextView.java:11081)
E/AndroidRuntime(10790): at android.widget.TextView.onTouchEvent(TextView.java:9588)
E/AndroidRuntime(10790): at android.view.View.dispatchTouchEvent(View.java:8981)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.widget.ScrollView.dispatchTouchEvent(ScrollView.java:615)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
E/AndroidRuntime(10790): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
E/AndroidRuntime(10790): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2568)
E/AndroidRuntime(10790): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1776)
E/AndroidRuntime(10790): at android.app.Activity.dispatchTouchEvent(Activity.java:2866)
E/AndroidRuntime(10790): at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
E/AndroidRuntime(10790): at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:59)
E/AndroidRuntime(10790): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2529)
E/AndroidRuntime(10790): at android.view.View.dispatchPointerEvent(View.java:9186)
E/AndroidRuntime(10790): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4706)
E/AndroidRuntime(10790): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImp
xml文件:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<EditText
android:id="@+id/claim_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/textbox"
android:hint="@string/claim_title"
android:inputType="textCapSentences"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
android:textColor="@color/Gray"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin" />
<EditText
android:id="@+id/claim_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/commentbox"
android:gravity="top"
android:hint="@string/claim_desc"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
android:textColor="@color/Gray"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
活动代码:
public class NewClaimActivity extends ActionBarActivity implements
RestClientCallback, OnClickListener {
private EditText claimTitle;
private EditText claimDesc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_claim);
claimTitle = (EditText) findViewById(R.id.claim_title);
claimDesc = (EditText) findViewById(R.id.claim_desc);
}
@Override
public void onClick(View v) {
String title = claimTitle.getText().toString();
String desc = claimDesc.getText().toString();
}
}
编辑文本的屏幕截图:
感谢您的帮助。
答案 0 :(得分:0)
这是Android源代码中的known bug,here's a workaround代表它(你必须继承TextView)
答案 1 :(得分:0)
我一直面临类似的问题。虽然无法理解为什么会这样,但我能够通过从布局文件中删除一行来解决它。
在xml文件中,删除以下内容:
<强>机器人:的inputType =&#34; textCapSentences&#34; 强>