技术开发 频道

Windows Mobile与OPhone开发对比

  最后是AndroidManifest.xml. 你每次添加一个Acivity都需要在这个文件中描述一下。

  看一下代码:

public class HelloWolrd extends Activity {  
    
/** Called when the activity is first created. */  
    @Override  
    
public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
  
        
//指定这个Activity的界面布局,如果不指定,运行起来是默认空白的,如何布局后面讲述  
        setContentView(R.layout.main);          
      
//这句话就是用来获取layout中设置的界面控件对象的,这个id是在button中指定的  
           android:id
="@+id/button_normal"  
        Button btn
=(Button)this.findViewById(R.id.button_normal);  
          
        
//为btn添加响应函数  
        btn.setOnClickListener(
new OnClickListener(){  
  
            
public void onClick(View arg0) {  
                TextView tv
=(TextView)this.findeViewbyId(R.id.text);  
                        tv.setText(R.id.hello);  
            }  
              
              
        }  
        );  
    }  
}  
  
布局文件mani.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"  
    
>  
<TextView  android:id="@+id/text"  
    android:layout_width
="fill_parent"    
    android:layout_height
="wrap_content"    
    android:text
="@string/hello"  
    
/>  
<Button android:id="@+id/button_normal"  
            android:text
="@string/clickme"  
            android:layout_width
="wrap_content"  
            android:layout_height
="wrap_content" />  
</LinearLayout>  

  2:再来看一下Windows Mobile

  新建一个设备应用程序项目“Hello World”,如下图:

 

  屏幕左侧出现了一个可编辑的设计界面,我们要设计HelloWorld的界面,只需要从工具箱里拖拽一个button和一个lable。比起Android来,微软因为其强大的集成工具,让可视化的界面变成变得非常简单,所见即所得。

 

0
相关文章