重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
公司主营业务:网站设计、成都网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出织金免费做网站回馈大家。
界面文件activity_main.xml
界面文件result.xml
MainActivity.java
public class MainActivity extends ActionBarActivity { private EditText factor_one; private EditText factor_two; private TextView symbol; private Button multiply; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); factor_one = (EditText) findViewById(R.id.factor_one); factor_two = (EditText) findViewById(R.id.factor_two); symbol = (TextView) findViewById(R.id.symbol); multiply = (Button) findViewById(R.id.multiply); symbol.setText(R.string.symbol); multiply.setText("计算"); multiply.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String factor_one_str = factor_one.getText().toString(); String factor_two_str = factor_two.getText().toString(); Intent intent = new Intent(); intent.putExtra("factor_one_str", factor_one_str); intent.putExtra("factor_two_str", factor_two_str); intent.setClass(MainActivity.this, ResultActivity.class); MainActivity.this.startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) {//设置菜单 //MenuItem android.view.Menu.add(int groupId, int itemId, int order, int titleRes) menu.add(0, 1, 1, R.string.about); menu.add(0, 2, 2, R.string.exit); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) {//选中菜单选项之后进行的操作 if (item.getItemId() == 1) {//关于 }else if (item.getItemId() == 2) {//退出 finish(); } return super.onOptionsItemSelected(item); } }
ResultActivity.java
public class ResultActivity extends Activity{ private TextView result; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.result); String factor_one_str = getIntent().getStringExtra("factor_one_str"); String factor_two_str = getIntent().getStringExtra("factor_two_str"); int factor_one = Integer.parseInt(factor_one_str); int factor_two = Integer.parseInt(factor_two_str); result = (TextView) findViewById(R.id.result); result.setText(factor_one * factor_two + ""); } }
strings.xml
Activity_03 Hello world! Settings 乘以 退出 关于
AndroidManifest.xml 中注册Activity