Open ted-prnd opened 4 years ago
onCreate()
postDelay()
post()
final Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(new Runnable() { @Override public void run() { toolbar.setSubtitle("Added subtitle"); } }, 1000);
ToolbarLayoutListener
BLANK
Problem
onCreate()
(not xml), subtitle is not shown.postDelay()
,post()
https://github.com/InflationX/Calligraphy/blob/881f11fe37491aee56ae155eb1ae4ff0599373ae/CalligraphySample/src/main/java/io/github/inflationx/calligraphy3/sample/MainActivity.java#L34Reason
ToolbarLayoutListener
get toolbar's original subTitle and set blank string https://github.com/InflationX/Calligraphy/blob/881f11fe37491aee56ae155eb1ae4ff0599373ae/calligraphy/src/main/java/io/github/inflationx/calligraphy3/Calligraphy.java#L231ToolbarLayoutListener
set original subTitle to toolbar https://github.com/InflationX/Calligraphy/blob/881f11fe37491aee56ae155eb1ae4ff0599373ae/calligraphy/src/main/java/io/github/inflationx/calligraphy3/Calligraphy.java#L253onCreate()
is ignore.Solution
ToolbarLayoutListener
check toolbar's current subTitle.BLANK
, use original subtitle.BLANK
, user set toolbar's subtitle. so toolbar use current subtitle.