user3782779 user3782779 -4 years ago 126
Android Question

Get activity custom title view

In my activity I use custom title feature:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.myactivitylayout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.myactivitytitle);


This works well, I can see myactivitytitle.xml elements in title of activity.

Now, I need to edit programatically elements of myactivitytitle.xml to do something like this:

View titleView = getTitleView();//This is the function I need
EditText et = titleView.findViewById(R.id.text1);
et.setText(...


How I can get the view of the title to access its elements?

Answer Source

This is my main_activity.java. In my activity I use custom title (R.layout.mytitle). there is a TextView in my title. i can get this TextView and i can set it's text with this code.

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
    TextView krdTxt = (TextView) findViewById(R.id.Kredi);
    krdTxt.setText("Faturalı Abone ");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download