NHTorres
NHTorres

Reputation: 1538

TextView android is not displayed in the view

I have a problem with an item in the view of my Activity. I have the following item:

<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"/>

In one of the functions of my Activity I have the following code:

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("");
}

Output :

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

I thought the value was not getting is why I printed that contained my element TextView and effectively if it has the values seteo but the view is not shown, being the'm visibility by setting properly. It happens with this and 2 more elements, whereas in others there is no error.

Upvotes: 1

Views: 42

Answers (1)

The Badak
The Badak

Reputation: 2050

try replacing

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

to:

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

Upvotes: 1

Related Questions