EditText not rendering correctly when added as a header of ListView

by Don Oleary » Sun, 07 Jun 2009 06:05:07 GMT

Sponsored Links
 Hi Guys

I have come across a problem where EditText is not rendering correctly when
it's added as a header in a ListView.
Basically, I have a search box and a list of results from a DB. The Activity
extends ListActivity and I add the search
box as a header using ListView.addHeaderView(View v).

On first load, the EditText view acts as normal. Every time I type a
character, it renders in the EditText. On any subsequent load of the
ListView, the EditText view "appears" unresponsive. If, for example, I type
another character, it does not render in the EditText view.  However,
when the ListView is updated, the EditText view updates with the relevant
changes. I get the same behaviour if I change the orientation
of the screen. When I type in EditText, the characters are not rendered to
the view. If I change orientation however, the EditText view is updated.

Any help in this regard would be very much appreciated.

Below is a code example to illustrate the problem.


public class ResultList extends ListActivity {

    DBAdapter mDb;
    EditText mQuery;

    public void onCreate(Bundle savedInstanceState) {

        mDb = new DBAdapter(this);



    protected void renderUI(){

        TableLayout headerTable = new TableLayout(this);

        TableRow row = new TableRow(this);

        row = new TableRow(this);

        mQuery = new EditText(this);
        mQuery.setHint("Search ");

        ImageButton search = new ImageButton(this);
        Bitmap bitmap =
        search.setPadding(10, 0, 0, 0);

        search.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {


        ListView list = (ListView)findViewById(android.R.id.list);


    private void populateResults(String search){


        Cursor expCur = mDb.getResults(search);


        String[] from = new String[] { mDb.KEY_DATE_STRING_VALUE};
        int[] to = new int[] { R.id.result_row_date};

        // Now create an array adapter and set it to display using our row
        SimpleCursorAdapter adapter =
            new SimpleCursorAdapter(this, R.layout.result_rows, expCur,
from, to);





Other Threads

1. Another Moseycode release

I'm pleased to announce that I've finally found the time to publish
the latest version of Moseycode - an application for interactive
augmented reality barcodes. I've been sitting on it for a couple of
weeks and have only now found the time to publish it.

This version of the application is broadly the same as that submitted
to the ADC with the exception that the version for submitted judging
was pre-configured with a test account and did not include support for
existing barcode symbologies (eg, QR Code, EAN and UPC). Adding
support for these was the thrust of this release.

The "Short User Guide" (pdf) should provide a good overview (this is
derived from the readme supplied to the ADC judges):


The documentation has been further extended to describe the increasing
number of ways that other Android applications can make use of
Moseycode's functionality, any interested Android developers may want
to take a look at:


As usual the screenshots and videos are collected here:


As ever feel free to send on any comments.


2. Taking a breather

Guys, I'm going to need to take a breather from this list as well. I
unsubscribed from the challenge list because of all of what went on with the
ADC and now this latest SDK move really has me boiling again. I'm not sure
that I can take any more announcements. Any follow up to threads on this dev
list, please go here: 

3. Problem with the heap size

4. Mobilogger project first release

5. When will the next version of SDK be published

6. How to "return" to an activity (Or how to terminate an activity)?

7. Deleting phone numbers and addresses