package com.example.Jsj;import androID.app.Activity;import androID.os.Bundle;import androID.vIEw.Menu;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import androID.vIEw.VIEw.OnClickListener;import androID.Widget.button;import androID.Widget.EditText;import androID.Widget.RadioGroup;import androID.Widget.TextVIEw;public class MainActivity extends Activity { EditText shuone; EditText shutwe; RadioGroup rag; button but_five; TextVIEw jg; int Result=0; int shuone1=0; int shutwe1=0; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); shuone = (EditText) findVIEwByID(R.ID.one); shutwe = (EditText) findVIEwByID(R.ID.twe); rag = (RadioGroup) findVIEwByID(R.ID.rag); jg = (TextVIEw) findVIEwByID(R.ID.text_one); but_five = (button) findVIEwByID(R.ID.but_five); rag.setonCheckedchangelistener(new RadioGroup.OnCheckedchangelistener() { @OverrIDe public voID onCheckedChanged(RadioGroup group, int checkedID) { shuone1= Integer.parseInt(shuone.getText().toString().trim()); shutwe1= Integer.parseInt(shutwe.getText().toString().trim()); // Todo auto-generated method stub String a =""; switch (checkedID) { case R.ID.but_one: a= shuone1+shutwe1+""; break; case R.ID.but_twe: a = shuone1-shutwe1+""; break; case R.ID.but_three: a= shuone1*shutwe1+""; break; case R.ID.but_four: a= shuone1/shutwe1+""; break; } jg.setText(a); } }); but_five.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw vIEw) { // Todo auto-generated method stub jg.setText(null); shuone.setText(null); shutwe.setText(null); } }); } @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @OverrIDe public boolean onoptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroIDManifest.xml. int ID = item.getItemID(); if (ID == R.ID.action_settings) { return true; } return super.onoptionsItemSelected(item); }}
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" androID:background="#e7e7e7" androID:paddingBottom="@dimen/activity_vertical_margin" androID:paddingleft="@dimen/activity_horizontal_margin" androID:paddingRight="@dimen/activity_horizontal_margin" androID:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.Jsj.MainActivity" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="vertical" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="horizontal"> <TextVIEw androID:layout_wIDth="0dp" androID:layout_height="30dp" androID:layout_weight="1" androID:text="输入第一个数" androID:layout_margintop="20dp"/> <EditText androID:ID="@+ID/one" androID:layout_wIDth="0dp" androID:layout_height="30dp" androID:background="#ffffff" androID:layout_weight="2" androID:layout_margintop="20dp"> </EditText> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="horizontal" > <TextVIEw androID:layout_wIDth="0dp" androID:layout_height="30dp" androID:layout_weight="1" androID:text="输入第二个数" androID:layout_margintop="20dp"/> <EditText androID:ID="@+ID/twe" androID:layout_wIDth="0dp" androID:layout_height="30dp" androID:background="#ffffff" androID:layout_weight="2" androID:layout_margintop="20dp"> </EditText> </linearLayout> </linearLayout> <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="vertical" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" androID:orIEntation="horizontal" > <RadioGroup androID:ID="@+ID/rag" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="horizontal" > <Radiobutton androID:ID="@+ID/but_one" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:textSize="25dp" androID:layout_weight="1" androID:text="+" /> <Radiobutton androID:ID="@+ID/but_twe" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:textSize="25dp" androID:layout_weight="1" androID:text="—" /> <Radiobutton androID:ID="@+ID/but_three" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:textSize="25dp" androID:layout_weight="1" androID:text="*" /> <Radiobutton androID:ID="@+ID/but_four" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:textSize="25dp" androID:layout_weight="1" androID:text="/" /> </RadioGroup> </linearLayout> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" > <TextVIEw androID:ID="@+ID/text_one" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textSize="25dp" androID:text="计算机结果显示在这" androID:layout_centerInParent="true" /> </relativeLayout> </linearLayout> <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1" > <button androID:ID="@+ID/but_five" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_centerInParent="true" androID:text="清空"/> </relativeLayout> </linearLayout>总结
以上是内存溢出为你收集整理的第四次作业全部内容,希望文章能够帮你解决第四次作业所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)