Add custom view as a view of XML layout

前端 未结 2 1562
死守一世寂寞
死守一世寂寞 2020-12-22 03:57

The scenario is the following:

I have an activity RunTrainingWorkoutsView that uses XML layout _run_workout.xml_ with some labels that are updated by Co

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-22 04:44

    I got it after 3 days of banging my head against the wall and by googling, stacOverflowing etc.

    Actually, it was this stupid little thing...

    My XML file where I defined the layout containing some usual android views (textView and buttons namely) and my custom view CounterClockView I had:

    
    

    where I had to have added one more line!

    
    
    

    I have no idea why this namespace line made such a huge difference, but it works great!

    Now, I can update my custom view from my main activity on every onTick() of CountDownTimer()...

    The following answer was very helpful: findViewById() returns null for custom component in layout XML, not for other components

提交回复
热议问题