gpt4 book ai didi

android - 包含链接的 EditText 在三星设备上崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:09:08 25 4
gpt4 key购买 nike

好的,这段代码在任何其他设备上都可以正常工作,但在三星设备上会崩溃。我似乎无法弄清楚为什么真的,但我知道如果我使用 TextView 它不会崩溃。但问题是,我需要一个 EditText 这个字段,它可以包含多个链接。在过去的一天里,我一直在寻找无济于事的解决方案,所以我想我会在这里发帖:

注意:这似乎适用于我测试过的 Nexus 和摩托罗拉设备:是否有一些我可能错过的解决方法,因为我猜测三星正在研究如何处理 EditText 框中的链接?

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText t3 = (EditText) findViewById(R.id.text3);
t3.setText(
Html.fromHtml(
"<b>text3:</b> Text with a " +
"<a href=\"http://www.google.com\">link</a> " +
"created in the Java source code using HTML."));
t3.setMovementMethod(LinkMovementMethod.getInstance());

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

}

如果有帮助,请查看堆栈跟踪:

    03-21 11:17:34.897: E/AndroidRuntime(1810): FATAL EXCEPTION: main
03-21 11:17:34.897: E/AndroidRuntime(1810): java.lang.NullPointerException
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.widget.Editor.onTouchUpEvent(Editor.java:1927)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.widget.TextView.onTouchEvent(TextView.java:8865)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.View.dispatchTouchEvent(View.java:7817)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-21 11:17:34.897: E/AndroidRuntime(1810): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
03-21 11:17:34.897: E/AndroidRuntime(1810): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
03-21 11:17:34.897: E/AndroidRuntime(1810): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.View.dispatchPointerEvent(View.java:8025)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4668)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4556)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4261)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4318)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4207)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4176)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4184)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4150)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6302)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6240)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6211)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6382)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.os.MessageQueue.nativePollOnce(Native Method)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.os.MessageQueue.next(MessageQueue.java:132)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.os.Looper.loop(Looper.java:124)
03-21 11:17:34.897: E/AndroidRuntime(1810): at android.app.ActivityThread.main(ActivityThread.java:5455)
03-21 11:17:34.897: E/AndroidRuntime(1810): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 11:17:34.897: E/AndroidRuntime(1810): at java.lang.reflect.Method.invoke(Method.java:525)
03-21 11:17:34.897: E/AndroidRuntime(1810): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-21 11:17:34.897: E/AndroidRuntime(1810): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-21 11:17:34.897: E/AndroidRuntime(1810): at dalvik.system.NativeStart.main(Native Method)

最佳答案

Clickable links and copy/paste menu in EditView in android

如果有人对答案感兴趣,这篇文章对我有帮助。

关于android - 包含链接的 EditText 在三星设备上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22563891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com