簡體   English   中英

視圖中未顯示TextView android

[英]TextView android is not displayed in the view

我的活動視圖中的某個項目有問題。 我有以下物品:

<TextView android:id="@+id/numero_asiento_alert"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="@string/msg_numero_alert"
                android:textColor="@color/result_minor_text"
                android:textStyle="bold"
                android:layout_marginLeft="25dip"
                android:paddingRight="4dip"
                android:textSize="22sp"/>

在我的活動的功能之一中,我具有以下代碼:

if(!inscripcion.getAsiento().equals("") && !inscripcion.getAsiento().equals("null")){
    asientoTextView = (TextView) findViewById(R.id.numero_asiento_alert);
    asientoTextView.setVisibility(View.VISIBLE);
    asientoTextView.setText("Asiento: "+inscripcion.getAsiento());
    System.out.println("Asiento "+asientoTextView.toString()+" "+asientoTextView.getText());
}else{
    asientoTextView = (TextView) findViewById(R.id.numero_asiento_alert);
    asientoTextView.setText("");
}

輸出:

08-04 10:50:44.537: I/System.out(6750): Asiento android.widget.TextView{418e3140 V.ED.... ......I. 0,0-0,0 #7f090050 app:id/numero_asiento_alert} Asiento: Fila B - Asiento 4

我以為沒有得到值就是為什么我打印包含TextView元素的原因,並且如果它具有seteo值但實際上未顯示視圖,則可以進行打印,這是正確設置的可見性。 這與另外2個元素一起發生,而在其他元素中則沒有錯誤。

嘗試更換

if(!inscripcion.getAsiento().equals("") && !inscripcion.getAsiento().equals("null")){

至:

if (inscripcion.getAsiento() != null) if (!inscripcion.getAsiento().isEmpty() && !inscripcion.getAsiento().equals("")) {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM