Android¥¢¥×¥ê¤ò³«È¯¤¹¤ë¤¿¤á¤Î´ðÁäò¤Þ¤È¤á¤Æ¤¢¤ê¤Þ¤¹¡£


¥é¥¸¥ª¥Ü¥¿¥ó¤ò»È¤Ã¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó

¥é¥¸¥ª¥Ü¥¿¥ó¤ò»È¤Ã¤¿Îã¤È¤·¤Æ¡¢°§»¢¤òɽ¼¨¤¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¤Ä¤¯¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¤Þ¤º½é¤á¤Ë

°Ê²¼¤Î¤è¤¦¤Ê¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤·¤Æ²¼¤µ¤¤¡£
¹àÌÜÀßÄêÆâÍÆ
Project Namegreeting
Applecation Namegreeting
Package Namejp.co.example.greet
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ÎºîÀ®MainActivity
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥ÈAndroid 2.2
¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲåÁ¥§¥Ã¥¯¤¹¤ë

¥ì¥¤¥¢¥¦¥ÈXML(res/layout/main.xml)¤ò½ñ¤­´¹¤¨¤ë

<?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>

MainActivity.java¤ò¼¡¤Î¤è¤¦¤Ë½ñ¤­´¹¤¨¤ë

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);
			}
		});
//---------------------------------------------------------------------------------------------
//¢¬ ¤³¤³¤Þ¤Ç
//---------------------------------------------------------------------------------------------
	}
}
¤³¤Î¤è¤¦¤Ëɽ¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
¡ÖÄ«¡×¡ÖÃë¡×¡ÖÈաפΤ¤¤Å¤ì¤«¤òÁªÂò¤·¡¢°§»¢¤ò¤¹¤ë¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£

­¤·»»

­¤·»»¤ò¹Ô¤¦¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¤Ä¤¯¤Ã¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¤Þ¤º½é¤á¤Ë

°Ê²¼¤Î¤è¤¦¤Ê¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤·¤Æ²¼¤µ¤¤¡£
¹àÌÜÀßÄêÆâÍÆ
Project Namecalculation
Applecation Name­¤·»»
Package Namejp.co.example.calc
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ÎºîÀ®CalculationActivity
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥ÈAndroid 2.2
¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲåÁ¥§¥Ã¥¯¤¹¤ë

¥ì¥¤¥¢¥¦¥ÈXML(res/layout/main.xml)¤ò½ñ¤­´¹¤¨¤ë

<?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>

CalculationActivity.java¤ò¼¡¤Î¤è¤¦¤Ë½ñ¤­´¹¤¨¤ë

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();
			}
		});
//---------------------------------------------------------------------------------------------
//¢¬ ¤³¤³¤Þ¤Ç
//---------------------------------------------------------------------------------------------
	}
}
¤³¤Î¤è¤¦¤Ëɽ¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
¼ÂºÝ¤Ë¡¢ÃͤòÆþÎϤ·¡¢¡Ö·×»»¤¹¤ë¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£

¤³¤Î¥Ú¡¼¥¸¤Ø¤Î¥³¥á¥ó¥È

wf8OGI <a href="http://cryuxvwkcfcq.com/">cryuxvwkcfcq</a>, [url=http://uppfojyyzkqr.com/]uppfojyyzkqr[/url], [link=http://sxrxngbfqrro.com/]sxrxngbfqrro[/link], http://ezlrrzttqyzi.com/

0
Posted by tdypsvfxzge 2013ǯ11·î14Æü(ÌÚ) 10:43:35 ÊÖ¿®

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹