Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 省略号禁用初始文本_Java_Android_Android Widget - Fatal编程技术网

Java 省略号禁用初始文本

Java 省略号禁用初始文本,java,android,android-widget,Java,Android,Android Widget,我使用带有按钮的singleLine=true和ellipsize=start时有一种奇怪的行为 首先,我的按钮声明: <Button android:id="@+id/enterDeparture" android:layout_width="175dp" android:layout_height="30dp" android:layout_marginLeft="10dp" android:background="@drawable/field

我使用带有按钮的
singleLine=true
ellipsize=start
时有一种奇怪的行为

首先,我的按钮声明:

<Button
    android:id="@+id/enterDeparture"
    android:layout_width="175dp"
    android:layout_height="30dp"
    android:layout_marginLeft="10dp"
    android:background="@drawable/field_button"
    android:text="@string/research_enterDeparture"
    android:textColor="@drawable/field_button_textcolor"
    android:paddingLeft="3dp"
    android:paddingRight="3dp"
    android:ellipsize="start"
    android:singleLine="true" />

使用此声明时,按钮内不显示任何文本。但是如果我写
Log.d(TAG),那么文本是:“+findviewbyd(R.id.enterbeforation)),LogCat给了我正确的值

我试图通过编程方式设置文本,无论是在
onCreateView()
还是在
onResume()方法中:相同的行为。但是如果我在屏幕上放置AlertDialog之后设置文本,内容会立即返回

最后,如果我删除android:ellipsize=“start”
android:singleLine=“true”
两行,一切正常:我的文本第一次显示

编辑

我试图删除
singleLine=true
行:初始内容实际显示,但省略行为不再起作用


因此,我尝试使用
maxLines=1
:显示初始内容,但不再显示“…”(内容只是被截断)。

尝试更改高度值:

android:layout_height="wrap_content"
您可能正在删除您的文本以。。。而且因为按钮填充,它可能被隐藏了

此外,您还想尝试以下方法:

Log.d(TAG, "the text is : " + ((Button)findViewById(R.id.enterDeparture)).getText())

这不会改变任何事情。但是,我需要固定的高度。