I have implemented a Section header Listview where i inflate a layout which have three textviews in it as item.i have referred this example here to achieve it.
My code is
adapter.addSection(monthitems2[l], new SimpleAdapter(this, security, R.layout.phone_row,
new String[] {"Title", "Caption","val1" }, new int[] { R.id.tvContact, R.id.tvMobile,R.id.tvMail }));
I have a condition where i need to change text color of ID “R.id.tvContact”.I havent defined the textview anywhere in thelayout.i have just referred it as simpleadapter parameter.How to change the textview color the default is white.Any suggestions answers are highly appreciated.
From the reference tutorial, you have
Get a handle to your TextView, then set its color from that handle. You need to Post the
commands to the message queue, in a runnable, b/c at this point in the code the ListView hasn’t yet rendered the TextView’s that the adapter points to (that will happen sometime after OnCreate exits).
I don’t think you need to qualify FindViewById with list. b/c you set the content view with
(above code in C# for MonoDroid, easily convertable to Java).
Posting runnables in Java/Android: How to run a Runnable thread in Android?
Posting in runnables puts the code in the message queue, a key, undocumented construct in Android. Anytime you get a null reference from an activity when modifying Views, try this as a first step.