草庐IT

java - 错误 : SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

coder 2023-08-03 原文

我的 Android 应用程序出现问题。我有一个按钮和事件关联,但是当我第一次点击时出现错误

"spans cannot have zero lenght".

.但是当我第二次点击时,事件 onclick 运行良好.. 看看我的 Java 代码:

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    final Button selectAltitude = (Button) findViewById(R.id.buttonAltitude1);
    final Button selectAltitude2 = (Button) findViewById(R.id.buttonAltitude2); 
    
    selectAltitude2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view){
            
                String tempAlt = selectAltitude2.getText().toString();
                selectAltitude2.setText(selectAltitude.getText().toString());
                selectAltitude.setText(tempAlt);
        }
    });
    }

带有两个按钮的 xml 代码(出现弃用警告):

 <?xml version="1.0" encoding="utf-8"?> 
<AbsoluteLayout
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:background="@android:color/black"> 

<Button
        android:id="@+id/buttonAltitude1"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="39dp"
        android:layout_height="42dp"
        android:layout_marginLeft="250dp"
        android:layout_x="257dp"
        android:layout_y="419dp"
        android:background="@drawable/drawable1"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical"
        android:includeFontPadding="false"
        android:linksClickable="true"
        android:minHeight="10dp"
        android:minWidth="64dp"
        android:paddingLeft="10dp"
        android:paddingRight="5dp"
        android:scrollHorizontally="true"
        android:text="@string/button_meters"
        android:textColor="@android:color/black"
        android:textSize="22sp"
        android:textStyle="bold" />
        
        <Button
            android:id="@+id/buttonAltitude2"
            style="?android:attr/buttonBarButtonStyle"
            android:layout_width="65dp"
            android:layout_height="42dp"
            android:layout_marginLeft="250dp"
            android:layout_x="295dp"
            android:layout_y="419dp"
            android:background="@drawable/drawable2"
            android:clickable="true"
            android:focusableInTouchMode="true"
            android:gravity="center_vertical"
            android:includeFontPadding="false"
            android:linksClickable="true"
            android:minHeight="10dp"
            android:minWidth="64dp"
            android:paddingLeft="15dp"
            android:paddingRight="5dp"
            android:scrollHorizontally="true"
            android:text="@string/button_feet"
            android:textColor="@android:color/black"
            android:textSize="25sp"
            android:textStyle="bold" />

当我第一次点击 Log cat 交互时:

04-06 20:01:39.865: I/Sensors(6946): sendDelay --- 200000000 04-06

20:01:39.865: D/SensorManager(6946): JNI - sendDelay 04-06

20:01:39.865: I/SensorManager(6946): Set normal delay = true 04-06

20:01:39.890: E/SpannableStringBuilder(6946): SPAN_EXCLUSIVE_EXCLUSIVE

spans cannot have a zero length 04-06 20:01:39.890:

E/SpannableStringBuilder(6946): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot

have a zero length

你能帮我吗?;)

最佳答案

我在 LogCat 中遇到了相同的错误条目。就我而言,这是由我使用的第 3 方键盘引起的。当我将其改回 Android 键盘时,错误条目不再显示。

这是导致此问题的最可能原因,因为还有 SwiftKey 的错误报告:

http://support.swiftkey.net/forums/116693-2-bug-reports/suggestions/2994580-span-exclusive-exclusive-spans-cannot-have-a-zero-

关于java - 错误 : SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15839237/

有关java - 错误 : SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length的更多相关文章

随机推荐