Yeah that seems fine. Just stay away from internal/private APIs (and reflection tricks to get to them!).
On Fri, May 15, 2009 at 9:54 PM, iDeveloper <[email protected]> wrote: > Sob sob... Sorry to hurt you. Thats why I wanted to confirm before using > this. > I am already using custom title bar. What I ended up doing was I added the > title bar once, then every time I want to change it, I just change the > visibility to gone or visible depending on whether I want to show it or not. > That seems to work as well.... Please don't tell me thats not the right way > either :( > > > > > On 15-May-09, at 10:53 PM, Dianne Hackborn wrote: > > On Thu, May 14, 2009 at 11:11 PM, idev <[email protected]> wrote: > >> private void setCustomTitle(int value) { >> try { >> // retrieve value for >> com.android.internal.R.id.title_container >> int titleContainerId = (Integer) Class.forName( >> "com.android.internal.R$id").getField >> ("title_container").get(null); >> >> // remove all views from titleContainer >> ((ViewGroup) getWindow().findViewById >> (titleContainerId)).removeAllViews(); > > > Good lord, DO NOT DO THIS. Do you see what you are doing? You are using > reflection to get at private information, and then using that information to > rip apart the system's decoration layout. You WILL break in the future. I > guarantee it. > > Please, for me, slap whoever gave you this code. > > And yes, this is how setFeatureInt() works. It would be nice to have it be > more flexible, but for now you need to set these things up before > setContentView(). If you want a changing title bar, you'll need to set your > own custom title bar view up-front and just manage it all yourself. > > Okay now I am going to go cry silently in the corner. > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > > > > > > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

