0

可能重复:
在 PreferenceAcivity 中设置自定义标题栏

是否可以为 preferancActivity 添加自定义标题栏?

4

1 回答 1

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>
于 2012-08-06T05:36:20.937 回答