English 中文(简体)
简言之——如何孤立复杂的布局和补充另一个布局?
原标题:Android - how to inflate a complex layout and add to another layout?

I have an android question: I ve successfully created a countdown kitchen timer activity, however my goal is to have an activity that has 3 timers on it that all work independently. I created a separate layout just for the timer itself and moved the timer code into a class and I ve used layoutinflater to create the views and then added them into the linear layout for the activity. I get the layouts fine, however there s no functionality. There doesn t seem to be anything that ties the class code to the activity.

我如何对待这一点? 是否有任何人向我提出某种工作榜样?

页: 1

问题回答

Assuming you have inflated a view from an XML layout you could call findViewById(Int) on the inflated view to get a hold of any view in that layout. Then you could do the wireing manually, for instance adding a onClick listener to some button:

inflatedView.findViewById(ID_OF_SOME_BUTTON_IN_THE_INFLATED_VIEW).setOnClickListener(
   new View.OnClickListener() {
       public void onClick(View v) {
           // DO SOMETHING WHEN BUTTON IS CLICKED
       }
   });

这只是一个没有足够了解的情况。 最后,我所做的是,扩大我的班子的相对开支,并固定我的施工者,在班级中与活动相关的观点。 然后,在活动的正确规定中添加了这一看法。

感谢所有良好建议





相关问题
Very basic WPF layout question

How do I get this listbox to be maxiumum size, i.e. fill the group box its in. I ve tried width="auto" Height="auto", width="stretch" Height="stretch" annoyingly at the moment, it dynamicly sizes to ...

How to align the text to top of TextView?

How to align the text to top of a TextView? Equivalent Android API for Swings setInsets()? that is top of text should start be in (0,0) of TextView <?xml version="1.0" encoding="utf-8"?> <...

Centring a flow in Shoes

Can I center the contents of a flow in Shoes? I know that a paragraph can be centred like: para Centred paragrpah , :align=> center However, this does not work with flows: flow(:align=> ...

Overlaying with CSS

I want to load a website in an iframe, and overlay the website with some hints about the website that is shown. However, i got stuck at the point that the website has a variable passive white space at ...

How do you normally make a program look beautiful? [closed]

How can I make an Application look nice and not like an amateur pulled it together? I mean graphic-wise. Is there some sort of book you can read regarding beautiful program layouts, etc? I put this ...

热门标签