我想显示在我自己的页面上的自定义标题栏中。Android自定义标题栏进度
例如,我有10页,然后我将有10个水平点,标记的点是当前页面。
但我不知道如何动态地做到这一点。
我想要做这样的事情:将我的自定义的RelativeLayout的标题栏
getWindow().setsetFeatureInt(Window.FEATURE_CUSTOM_TITLE, new CustomTitleBar(this));
我读了很多关于它的东西,但我发现我我应该有一个xml做文件。 但是,我可以添加动态绘图到这个XML文件,然后!?或者我该怎么做?
编辑:
我真的不明白.. 我创建了一个XML布局文件现在:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</RelativeLayout>
,现在我想在某些按钮添加到它...
private void setTitleBar() {
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
RelativeLayout rl = (RelativeLayout)findViewById(R.id.bar);
rl.addView(new Button(this));
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
}
但是在rl.addView(new Button(this));我得到一个NullPointerException。 这是为什么!?
的XML的是静态并且在创建活动或布局时意味着被夸大。我认为这意味着您每次都必须重新创建这部分活动。不过,我听到[片段](http://developer.android.com/guide/topics/fundamentals/fragments.html)将允许你做到这一点,但只在api 11或更高... – L7ColWinters 2012-01-18 13:58:26