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

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

friends,

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

 


        
5条回答
  •  粉色の甜心
    2020-12-05 03:52

    my_title.xml

    
    
    
        
    
        
    
    

    Code:

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);      
    setContentView(R.layout.main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title);      
    
    ((TextView)findViewById(R.id.title)).setText("gradient shadow");
    
    findViewById(R.id.back).setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            ((TextView)findViewById(R.id.title)).setText("loce");
        }
    });
    

    Because custom title default is fixed you should write yourself a theme:

    
    

提交回复
热议问题