请问 为什么 要有xml布局文件呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText android:id="@+id/speed" android:maxLines="1"
android:layout_marginTop="2dip" android:layout_width="wrap_content"
android:ems="25" android:layout_height="wrap_content"
android:autoText="true" android:scrollHorizontally="true" /> <Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="这是button1" />
<Button android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="这是button2" />
</LinearLayout>比如上面这个
--------------------
他这个文件是不是要用java 读出来 然后解析的呀?
如果是的话。那干嘛不世界用java 呢→_→

解决方案 »

  1.   

    MVC模式,
    把视图,模型,控制分开,
    好处呢,一个便与维护,当然很有很多好处,做多了就慢慢能体会
      

  2.   

    因为android是典型的MVC设计模式,xml布局文件就是相当于视图。因为它的存在可以很好的分离应用程序中的控制器和模型层,让代码的通用性和灵活性更强
    举个例子,一个应用程序中有两个需要给用户展示的界面,界面一模一样,但是操作不同。
    那么就可以建一个XML布局文件,用两个Activity来展示同一个XML,但是各自的操作又写到不同的JAVA文件中。
      

  3.   

    这个不叫MVC,这只是用声明式编程去处理MVC里的V而已。
      

  4.   

    界面和处理逻辑分开,其实也可以用java代码直接写界面