0

I have problem with defining layout in my application. I have followed "notepad tutorial" on Android Development site, all is working excellent, but only thing I am not able to achieve is set ListView Item's height. Items are only as wide and high as its content is.

Here is my XML definition of the layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="fill_parent" android:layout_width="match_parent" android:orientation="vertical">
    <ListView android:layout_width="fill_parent" android:id="@+id/android:list" android:transcriptMode="alwaysScroll" android:layout_height="match_parent">
    </ListView>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/text1"
      android:layout_width="fill_parent"
      android:layout_height="80dp"  
      android:padding="10dp"
      android:textSize="16sp"/>

</LinearLayout>

In my code I am calling only in oncreate() method the entire ListView and then in this method, which is responsible for fill listitems with data from SQLLite

 private void fillData() {
    // Get all of the rows from the database and create the item list
    Cursor mNotesCursor = mDbHelper.fetchAllNotes();
    startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{NotesDbAdapter.KEY_TITLE};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
    setListAdapter(notes);

}

Even when I tried set some crazy values on my XML as TextView attributes, items height, textcolor, everything remained unchanged. I suppose its should be simple, but unfortunately I am not able to make it w

simekadam
  • 7,334
  • 11
  • 56
  • 79

1 Answers1

1

try to set the height in R.layout.notes_row

notes_row.xml is your item layout view

and so set required height for this layout.

this layout is passed in following adapter for the item

SimpleCursorAdapter notes = 
            new SimpleCursorAdapter(this, R.layout.notes_row, mNotesCursor, from, to);
kehnar
  • 1,387
  • 2
  • 12
  • 25
  • As I have supposed, it was just my failure..Thanks for your advice, although I actually resolved it myself:) I have been editing bad xml resource.. – simekadam Oct 12 '11 at 22:25