是否可以为preferancActivity添加自定义标题栏?
答案 0 :(得分:0)
public class Preferences extends PreferenceActivity {
protected TextView title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main_tab);
title = (TextView) findViewById(R.id.titleTvLeft);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
this.title.setText("Value");
}
}
///////在title_bar.xml中///////
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
fill_parent="" >
<TextView
android:id="@+id/titleTvLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="3dp"
android:textColor="#FFFFFF"
android:textStyle="bold" >
</TextView>
</RelativeLayout>