朋友,如何在android中動態設置自定義標題欄的TextView Value?
我曾嘗試使用以下titlebar.xml文件的代碼
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="This is my new title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/titletextcolor"
android:layout_marginLeft="25px"
android:paddingTop="3px"
/>
和Java代碼來顯示每個活動自定義標題欄創建自定義標題欄。
@Override
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
現在我想在每個活動中動態設置textview值任何人都可以指導我如何實現這一目標?
在這裏使用findviewbyid我沒有得到該文本視圖的參考設置值,因爲 主佈局不包含任何帶有這樣的名稱但mytitle的文本框。
任何幫助將appriciated。
教程我也跟着 HTTP: //stackoverflow.com/questions/2251714/set-title-background-color – UMAR 2010-03-10 12:43:50