Note that I am using Mono for Android
I have a ListView of items that can be extended by clicking a "More" button at the bottom of the list. The list is defined in XML but the more button is simply a clickable TextView that is added to the bottom of the list via AddFooterView. I am trying to apply a pre-defined style to the runtime-created TextView but it is not working.
mMoreProductsButton = new TextView(this, null, Resource.Style.more_button);
mMoreProductsButton.Text = "More";
mMoreProductsButton.Click += new EventHandler(MoreProductsButton_Click);
mListView.AddFooterView(mMoreProductsButton);
TextView documentation shows this signature: TextView(Context context, AttributeSet attrs, int defStyle)
defStyle
is defined in the documentation as the default style to apply to the view. An example I saw elsewhere passed null as the AttributeSet but I'm not sure if that is valid or related to my problem.
I found this bug and am not sure if it is related and current: http://code.google.com/p/android/issues/detail?id=12683
Any suggestions are appreciated!
I also searched answer to this question. It seems to be an Android bug because I didn't found a way of style applying to creating Views. Why don't you want to inflate your TextView?
Like this:
layout/my_view.xml
Activity
Sorry, I don't know if it workable in Mono.