现在的位置: 首页 > 综合 > 正文

Android Hello World

2018年05月22日 ⁄ 综合 ⁄ 共 609字 ⁄ 字号 评论关闭

 

布局文件

<EditText 
	android:id="@+id/factorOne"
	android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
/>

 

id 控件的ID ,在ACTIVITY 中可以通过R.id.myid得到控件 
 textView = (TextView)findViewById(R.id.myResultTextView);

 

 

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result);
        textView = (TextView)findViewById(R.id.myResultTextView);
        Intent intent = getIntent();
        String a =intent.getStringExtra("f1");
        String b =intent.getStringExtra("f2");
        Long result = Long.valueOf(a)*Long.valueOf(b);
        textView.setText(String.valueOf(result));
    }

setContentView(R.layout.result); 制定该ACTIVITY要使用的布局文件

 

抱歉!评论已关闭.