ºÇ½ª¹¹¿·¡§
t_yokky2002 2011ǯ10·î16Æü(Æü) 22:34:14ÍúÎò
¥é¥¸¥ª¥Ü¥¿¥ó¤ò»È¤Ã¤¿Îã¤È¤·¤Æ¡¢°§»¢¤òɽ¼¨¤¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¤Ä¤¯¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£
°Ê²¼¤Î¤è¤¦¤Ê¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤·¤Æ²¼¤µ¤¤¡£
¹àÌÜ | ÀßÄêÆâÍÆ |
---|---|
Project Name | greeting |
Applecation Name | greeting |
Package Name | jp.co.example.greet |
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ÎºîÀ® | MainActivity |
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥È | Android 2.2 |
¥ï¡¼¥¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲà | ¥Á¥§¥Ã¥¯¤¹¤ë |
<?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" android:background="#aaaaaa" > <RadioGroup android:id="@+id/time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <RadioButton android:id="@+id/morning" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="Ä«" /> <RadioButton android:id="@+id/afternoon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="Ãë" /> <RadioButton android:id="@+id/night" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="ÈÕ" /> </RadioGroup> <Button android:id="@+id/great" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="°§»¢¤ò¤¹¤ë" /> <TextView android:id="@+id/result" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" android:textColor="#FFFFFF" android:textSize="20sp" android:gravity="center" /> </LinearLayout>
public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //--------------------------------------------------------------------------------------------- // ¢¤³¤³¤«¤é //--------------------------------------------------------------------------------------------- final RadioGroup time = (RadioGroup) findViewById(R.id.time); Button great = (Button) findViewById(R.id.great); final TextView result = (TextView) findViewById(R.id.result); great.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String message = ""; switch (time.getCheckedRadioButtonId()) { case R.id.morning: message = "¤ª¤Ï¤è¤¦"; break; case R.id.afternoon: message = "¤³¤ó¤Ë¤Á¤Ï"; break; case R.id.night: message = "¤³¤ó¤Ð¤ó¤Ï"; break; } result.setText(message); } }); //--------------------------------------------------------------------------------------------- //¢¬ ¤³¤³¤Þ¤Ç //--------------------------------------------------------------------------------------------- } }
¤³¤Î¤è¤¦¤Ëɽ¼¨¤µ¤ì¤Þ¤·¤¿¤«¡© ¡ÖÄ«¡×¡ÖÃë¡×¡ÖÈաפΤ¤¤Å¤ì¤«¤òÁªÂò¤·¡¢°§»¢¤ò¤¹¤ë¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£
![](https://image02.seesaawiki.jp/g/d/genesix_android/81c92354133d82a9.png)
°Ê²¼¤Î¤è¤¦¤Ê¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤·¤Æ²¼¤µ¤¤¡£
¹àÌÜ | ÀßÄêÆâÍÆ |
---|---|
Project Name | calculation |
Applecation Name | ¤·»» |
Package Name | jp.co.example.calc |
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ÎºîÀ® | CalculationActivity |
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥È | Android 2.2 |
¥ï¡¼¥¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲà | ¥Á¥§¥Ã¥¯¤¹¤ë |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:paddingTop="10dp" android:background="#a0a0a0" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#a0a0a0"> <EditText android:id="@+id/value1" android:layout_width="100dp" android:singleLine="true" android:numeric="signed" android:layout_height="wrap_content" /> <TextView android:layout_width="30dp" android:layout_height="wrap_content" android:gravity="center" android:textColor="#000000" android:text="+" /> <EditText android:id="@+id/value2" android:layout_width="100dp" android:singleLine="true" android:numeric="signed" android:layout_height="wrap_content" /> </LinearLayout> <Button android:id="@+id/calc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="·×»»¤¹¤ë" /> </LinearLayout>
public class CalculationActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //--------------------------------------------------------------------------------------------- // ¢¤³¤³¤«¤é //--------------------------------------------------------------------------------------------- final EditText value1 = (EditText) findViewById(R.id.value1); final EditText value2 = (EditText) findViewById(R.id.value2); Button btn = (Button) findViewById(R.id.calc); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // ·×»»¤¹¤ë¥Ü¥¿¥ó²¡²¼»þ¤Ë¡¢¥¡¼¥Ü¡¼¥É¤ò¾Ã¤¹ InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); SpannableStringBuilder v1 = (SpannableStringBuilder) value1 .getText(); String val1 = v1.toString(); SpannableStringBuilder v2 = (SpannableStringBuilder) value2 .getText(); String val2 = v2.toString(); Long ans; try { ans = Long.parseLong(val1) + Long.parseLong(val2); } catch (NumberFormatException e) { // ¥È¡¼¥¹¥È¤òɽ¼¨ Toast.makeText(CalculationActivity.this, e.toString(), Toast.LENGTH_SHORT).show(); return; } // LogCat¤Ë½ÐÎÏ Log.i("anster", String.valueOf(ans)); // ¥È¡¼¥¹¥È¤òɽ¼¨ Toast.makeText(CalculationActivity.this, "·×»»·ë²Ì¤Ï " + String.valueOf(ans) + " ¤Ç¤¹", Toast.LENGTH_SHORT).show(); } }); //--------------------------------------------------------------------------------------------- //¢¬ ¤³¤³¤Þ¤Ç //--------------------------------------------------------------------------------------------- } }
¤³¤Î¤è¤¦¤Ëɽ¼¨¤µ¤ì¤Þ¤·¤¿¤«¡© ¼ÂºÝ¤Ë¡¢ÃͤòÆþÎϤ·¡¢¡Ö·×»»¤¹¤ë¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
![](https://image01.seesaawiki.jp/g/d/genesix_android/6d81a2b515483f05.png)
¤³¤Î¥Ú¡¼¥¸¤Ø¤Î¥³¥á¥ó¥È
wf8OGI <a href="http://cryuxvwkcfcq.com/">cryuxvwkcfcq</a>, [url=http://uppfojyyzkqr.com/]uppfojyyzkqr[/url], [link=http://sxrxngbfqrro.com/]sxrxngbfqrro[/link], http://ezlrrzttqyzi.com/