【发布时间】:2010-10-23 15:40:38
【问题描述】:
我在我的应用程序中为每个活动使用自定义标题视图。在其中一项活动中,基于按钮单击,我需要更改自定义标题视图。现在每次我调用 setFeatureInt 时都可以正常工作。
但是,如果我尝试更新自定义标题中的任何项目(例如更改按钮的文本或标题上的文本视图),则不会进行更新。
通过代码调试显示文本视图和按钮实例不为空,我还可以看到自定义标题栏。但是文本视图或按钮上的文本没有更新。有没有其他人遇到过这个问题? 我该如何解决?
谢谢。
编辑
这是我尝试过的。即使调用 postInvalidate 也不会更新。
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.text_title);
TextView databar = (TextView) findViewById(R.id.title_text);
databar.setText("Some Text");
databar.postInvalidate();
Button leftButton = (Button) findViewById(R.id.left_btn);
leftButton.setOnClickListener(mLeftListener);
leftButton.setText("Left Btn");
leftButton.postInvalidate();
Button rightBtn = (Button) findViewById(R.id.right_btn);
rightBtn.setOnClickListener(mRightListener);
rightBtn.postInvalidate();
【问题讨论】:
-
看到这个替代解决方案stackoverflow.com/questions/8634319/…
标签: android android-custom-view