K
K
kirchevsky2012-06-24 10:33:25
Android
kirchevsky, 2012-06-24 10:33:25

Can't display data in TextView (ListView)?

We have a ListView, and we also have this layout for the ListView elements (row.xml):

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android=" schemas.android.com/apk/res/android"
  3.           android:layout_height="wrap_content" 
  4.           android:layout_width="match_parent"
  5.           android:layout_gravity="top">
  6. <ImageView android:id="@+id/itemicon" 
  7.            android:src="@drawable/icon"
  8.        android:layout_marginLeft="4dp" 
  9.        android:layout_marginRight="8dp"
  10.        android:layout_height="30dp" 
  11.        android:layout_marginTop="8dp"
  12.        android:layout_width="30dp">
  13. </ImageView>
  14. <TextView  
  15.           android:layout_height="wrap_content" 
  16.           android:id="@+id/label"
  17.       android:textSize="25dp" 
  18.       android:layout_marginTop="6dp" 
  19.       android:layout_width="fill_parent" 
  20.       android:textColor="#000000">
  21. </TextView>
  22. <TextView   
  23.           android:id="@+id/labeldesc"
  24.       android:textSize="14dp" 
  25.       android:layout_marginTop="2dp" 
  26.       android:layout_width="wrap_content"
  27.       android:layout_height="wrap_content"
  28.       android:textColor="#000000">
  29. </TextView>
  30. </LinearLayout>

Using the SimpleCursorAdapter, we insert data into this Layout. By trial and error, it was possible to establish that the data in " id / label" is displayed perfectly, but when trying to display data in " id / labelesc" absolutely nothing is displayed. I understand in advance that the rake is somewhere very close, however, I personally have not yet been able to find the reason. At first I thought that the reason was somewhere in the code, but after rearranging the values, I see that the reason is in Layout or somewhere close, because any data set is normally displayed in id / label, while it does not want to be displayed in the second TextView at all.
Thanks in advance for your help and sorry for the (maybe) stupid questions...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MetAmfetamine, 2012-06-24
@MetAmfetamine

The TextView (label) takes up the remaining width of the LinearLayout after the ImageView, so the second TextView (labeldesc) just doesn't fit.
If you change the label's layout_width to wrap_content, then the text in the labeldesc will be visible (unless the text in the label takes up the full width).

P
Pavel Isakov, 2012-06-25
@kwikpik

If you want @+id/label to occupy the entire free area before @+id/labeldesc then add to the label android:layout_weight="0.9"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question