In general development, the title of the application is configured in the Androidmanifest.xml when the application is built, or a simple string set with Settitle, if you want to add more complex layouts such as buttons, pictures, etc., use the following method
- Function: Set title to be a string and a combination of buttons
- Modify the Xxactivity.java code
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Requestwindowfeature (Window.feature_custom_title); Note Order
Setcontentview (R.layout.main); Note Order
GetWindow (). Setfeatureint (Window.feature_custom_title,//Note order
R.layout.title);
}
- Add title.xml Code
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout
Xmlns:android=http://schemas.android.com/apk/res/android
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<textview android:id= "@+id/text"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_alignparentleft= "true"
android:text= "Text"/>
<button android:id= "@+id/button"
Android:layout_width= "Wrap_content"
android:layout_height= "30px"
android:text= "button"/>
</LinearLayout>
The following points need to be noted:
Note Set Order
Requestwindowfeature to Setcontentview before the
GetWindow (). Setfeatureinit Better after Setcontentview
Note Requestwindowfeature (Window.feature_custom_title) should not be used with other settings for TITLE requestwindowfeature (xxxx)
"Turn" http://bbs.androidcn.com/thread-1951-1-1.html