当前位置:操作系统 > 安卓/Android >>

Android编码实现软件界面

[java]  
package cn.itcast.code;  
  
import android.app.Activity;  
import android.os.Bundle;  
import android.view.ViewGroup;  
import android.widget.LinearLayout;  
import android.widget.TextView;  
  
public class MainActivity extends Activity {  
    /** Called when the activity is first created. */  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        LinearLayout linearLayout = new LinearLayout(this);  
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(  
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);  
        TextView textView = new TextView(this);  
        textView.setText(R.string.hello);  
        textView.setId(34);  
        LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(  
                ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);  
        linearLayout.addView(textView, textParams);  
          
        setContentView(linearLayout, layoutParams);  
         
    }  
}  
 
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,