创建控件编程控件

由网友(莫失莫忘°)分享简介:据我了解,Android部件需要RemoteViews,而不是观,之类的活动。我的问题:有没有办法完全避免XML,并建立整个布局用java code 替代问题:我能以某种方式检索查看,就像我会使用 findViewById(INT)?例如:的LinearLayout的LinearLayout =(的LinearLayo...

据我了解,Android部件需要RemoteViews,而不是观,之类的活动。

我的问题:有没有办法完全避免XML,并建立整个布局用java code

替代问题:我能以某种方式检索查看,就像我会使用 findViewById(INT)?例如:的LinearLayout的LinearLayout =(的LinearLayout)findViewById(R.id.xxx); 这样我可以访问的基地布局,并操纵不过我想

谢谢!

解决方案   

有没有办法完全避免XML,并建立整个布局用java code?

没有,对不起。 RemoteViews 在很大程度上依赖于布局的XML资源。虽然有一个 addView()方法,转身又增加了 RemoteViews ,并让你回到原点从你开始。

  

我可以以某种方式检索查看,就像我会用findViewById(INT)?

没有,因为没有查看在你的进程。您配置通过各种setter方法​​上的小部件 RemoteViews

c 点击按钮调出另一个窗体 Visual C 创建用户界面,编写程序代码

As far as I understand, android widgets need RemoteViews, instead of View, like activities.

My question: is there any way to completely avoid xml, and build the whole layout with java code?

Alternative question: can I somehow retrieve a View, like I would use findViewById(int)? For example: LinearLayout linearLayout=(LinearLayout)findViewById(R.id.xxx); This way I could access the base layout, and manipulate however I want to.

Thanks!

解决方案

is there any way to completely avoid xml, and build the whole layout with java code?

No, sorry. RemoteViews relies heavily on layout XML resources. While there is an addView() method, it turns around and adds another RemoteViews, and that puts you right back where you started from.

can I somehow retrieve a View, like I would use findViewById(int)?

No, because there is no View in your process. You configure the widgets via the various setter methods on RemoteViews.

阅读全文

相关推荐

最新文章