how to set custom title bar TextView Value dynamically in android?

前端 未结 5 2004
离开以前
离开以前 2020-12-05 03:20

friends,

i have created custom title bar using following titlebar.xml file with code

 


        
5条回答
  •  温柔的废话
    2020-12-05 03:54

    Try the following:

    @Override
    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);        
         requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
         setContentView(R.layout.main);
         getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
         TextView mytitletext = (TextView) findViewById(R.id.myTitle);
         mytitletext.setText("========= NEW TITLE ==========");
    }
    

    You can use the hierarchyviewer to see if your view is accessible (you will see its id in the hierarchy graph)

提交回复
热议问题