setContentView and dynamically changing native android UI

I have been making an Android app and was wanting to add dynamic UI elements natively e.g. ListViews

This was not working at all, even though the code was correct. For example this code called in the onCreate on OFActivity would show no items in the list.

    ListView table = (ListView)findViewById(;
    ArrayAdapter<String> itemsAdapter =
            new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mobileArray);

And it turns out that anything done after the


in the initView() method of doesnt work .For example, updating the content of a listview with an adapter (as in the content is never updated on screen) or setting a click handler on a button programmatically (callback never called).

So I’ve commented ofActivity.setContentView(view) out in and called


At the top of the onCreate function in OFActivity. Obviously this is super hacky, is there a better workaround?