【发布时间】:2015-04-02 08:48:32
【问题描述】:
当我们做initializion of views 时,我有一个想法来摆脱一些编码。
当我们在 android 中创建 xml layout 时。在该运动中,同名class 是用UpperCase Letters 创建的,并带有许可对话。当我创建带有 id 的视图时。它应该自动创建视图并初始化它们。
例如
关闭.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/closeBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/close_img" />
<TextView
android:id="@+id/closeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Testing Text" />
</LinearLayout>
而且应该是自动生成的java代码。
public class Close extends Activity
{
TextView CloseText;
Button CloseBtn;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CloseText = (TextView)findViewById(R.id.closeText);
CloseBtn = (Button)findViewById(R.id.closeBtn);
}
}
我可以阅读 xml 并按照我解释的那样做其他事情。但是我怎么能把这个模块添加到 eclipse 中,我怎么能创建一个在 eclipse 中一直在后台工作的服务。
建议我如何将此模块(插件)添加到 Eclipse,我将使用 JAXB to generate Java Objects from XML document。有没有更好的选择。
【问题讨论】:
-
1.off-topic as 要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是题外话 2. 已经回答(我很确定我上周看到了类似的问题)... 3. 有很多基于注释的库
-
那么你为什么不分享一个@Selvin。这意味着如果您没有答案,那么请投反对票。以及我要求推荐一本书、软件等的地方。
标签: android xml class xml-parsing jaxb