ºÇ½ª¹¹¿·¡§
t_yokky2002 2011ǯ08·î23Æü(²Ð) 15:43:04ÍúÎò
²èÌ̺îÀ®¡¢²èÌÌÁ«°Ü¤òÂ賤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¤³¤³¤Ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ê²èÌÌÁ«°Ü¤ò¹Ô¤¦¾ì¹ç¤Î¡¢¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤È¥¤¥ó¥Æ¥ó¥È¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎºîÀ®¤ò¹Ô¤¤¤Þ¤¹¡£
¤³¤³¤Ç¤Ï¡¢¼¡¤Î¤è¤¦¤Ê²èÌÌÁ«°Ü¤ò¹Ô¤¦¾ì¹ç¤Î¡¢¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤È¥¤¥ó¥Æ¥ó¥È¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎºîÀ®¤ò¹Ô¤¤¤Þ¤¹¡£
¡Ö¥À¥¤¥¢¥é¡¼µ¯Æ°¡×¡¢¡Ö¥Ö¥é¥¦¥¶µ¯Æ°¡×¡¢¡Ö²èÌÌÁ«°Ü¡×¥Ü¥¿¥ó¤ò²¡²¼¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ³Æ²èÌ̤ËÁ«°Ü¤·¤Þ¤¹¡£
ÅÀÀþÆâ¤Îµ½Ò¤òÄɲ䷤Ƥ¯¤À¤µ¤¤¡£
<?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"> <Button android:id="@+id/Button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="¥À¥¤¥¢¥é¡¼µ¯Æ°" /> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¤³¤³¤«¤é --> <!-- -------------------------------------------------------------------------------- --> <Button android:id="@+id/Button2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="¥Ö¥é¥¦¥¶µ¯Æ°" /> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¬¤³¤³¤Þ¤Ç --> <!-- -------------------------------------------------------------------------------- --> <Button android:id="@+id/Button3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="²èÌÌÁ«°Ü" /> </LinearLayout>
¥á¥¤¥ó²èÌ̤ÎActivity¥¯¥é¥¹¡Êsrc/jp.co.test/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); // ¥À¥¤¥¢¥é¡¼¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤È¤ Button dialButton = (Button) findViewById(R.id.Button1); dialButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_DIAL); // ÅÅÏÃÈÖ¹æ¤òÀßÄê Uri uri = Uri.parse("tel:09012345678"); intent.setData(uri); startActivity(intent); } }); // ¥Ö¥é¥¦¥¶¡¼¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤È¤ //-------------------------------------------------------------------------------- //¢¤³¤³¤«¤é //-------------------------------------------------------------------------------- Button browzerButton = (Button) findViewById(R.id.Button2); browzerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse("http://ecnavi.jp/"); intent.setData(uri); startActivity(intent); } }); //-------------------------------------------------------------------------------- //¢¬¤³¤³¤Þ¤Ç //-------------------------------------------------------------------------------- // ²èÌÌÁ«°Ü¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤È¤ } }
¤³¤³¤Þ¤Ç´°Î»¤·¤¿¤é¡¢¥×¥í¥¸¥§¥¯¥È¤ò¼Â¹Ô¤·¥¨¥ß¥å¥ì¡¼¥¿¤ÇÆ°ºî³Îǧ¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£ ¡Ö¥Ö¥é¥¦¥¶¤òµ¯Æ°¡×¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤é¡¢¥Ö¥é¥¦¥¶¤¬µ¯Æ°¤·¡¢ÌÜŪ¤Î¥³¥ó¥Æ¥ó¥Ä¤¬É½¼¨¤µ¤ì¤Þ¤·¤¿¤«¡©
¥á¥¤¥ó²èÌ̤ǡ¢¡Ö²èÌÌÁ«°Ü¡×¥Ü¥¿¥ó¤¬²¡²¼¤µ¤ì¤¿»þ¤Î¡¢Á«°ÜÀè²èÌÌ¡ÊSubActivity¡Ë¤òÄɲä·¤Þ¤¹¡£
¥Ñ¥Ã¥±¡¼¥¸¥¨¥¯¥¹¥×¥í¡¼¥é¡¼¤Ç¡¢¥×¥í¥¸¥§¥¯¥È¤òÁªÂò¤·¤¿¾õÂ֤ǡ¢¡Ö±¦¥¯¥ê¥Ã¥¯¡×¢ª¡Ö¿·µ¬¡×¢ª¡Ö¥¯¥é¥¹¡×¤òÁªÂò¤·¤Þ¤¹¡£
¥Ñ¥Ã¥±¡¼¥¸¥¨¥¯¥¹¥×¥í¡¼¥é¡¼¤Ç¡¢¥×¥í¥¸¥§¥¯¥È¤òÁªÂò¤·¤¿¾õÂ֤ǡ¢¡Ö±¦¥¯¥ê¥Ã¥¯¡×¢ª¡Ö¿·µ¬¡×¢ª¡Ö¥¯¥é¥¹¡×¤òÁªÂò¤·¤Þ¤¹¡£
ɽ¼¨¤¹¤ë¥ì¥¤¥¢¥¦¥È¤È¤ÎɳÉÕ¤±Éôʬ¤òµ½Ò¤·¤Þ¤¹¡£ÅÀÀþÆâ¤ÎÆâÍƤòÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
µ½Ò¤·¤¿¤é¡¢¥Õ¥¡¥¤¥ë¤òÊݸ¤·¤ÆÊĤ¸¤Æ¤¯¤À¤µ¤¤¡£
µ½Ò¤·¤¿¤é¡¢¥Õ¥¡¥¤¥ë¤òÊݸ¤·¤ÆÊĤ¸¤Æ¤¯¤À¤µ¤¤¡£
¢¨¥¨¥é¡¼¤¬½Ð¤Æ¤¤¤ë¤È»×¤¤¤Þ¤¹¤¬¡¢¥ì¥¤¥¢¥¦¥È¤È¤·¤Æ»ÈÍѤ¹¤ëXML¥Õ¥¡¥¤¥ë¤¬¤Ê¤¤¤¿¤á¤Ç¤¹¡£
public class SubActivity extends Activity { //-------------------------------------------------------------------------------- //¢¤³¤³¤«¤é //-------------------------------------------------------------------------------- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sub); } //-------------------------------------------------------------------------------- //¢¬¤³¤³¤Þ¤Ç //-------------------------------------------------------------------------------- }
¥ì¥¤¥¢¥¦¥ÈÄêµÁ¥Õ¥¡¥¤¥ë¡Êres/layout/sub.xml¡Ë¤Ë²èÌ̥쥤¥¢¥¦¥È¤òµ½Ò¤·¤Þ¤¹¡£
ÅÀÀþÆâ¤Îµ½Ò¤òÄɵ¤·¤Æ¡¢Êݸ¤·¤Æ¤¯¤À¤µ¤¤¡£
ÅÀÀþÆâ¤Îµ½Ò¤òÄɵ¤·¤Æ¡¢Êݸ¤·¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¤³¤³¤«¤é --> <!-- -------------------------------------------------------------------------------- --> <TextView android:id="@+id/textView01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="¥µ¥Ö¥¢¥¯¥Æ¥£¥Ó¥Æ¥£²èÌ̤ËÁ«°Ü¤·¤Þ¤·¤¿" /> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¬¤³¤³¤Þ¤Ç --> <!-- -------------------------------------------------------------------------------- --> </LinearLayout>
¥Þ¥Ë¥å¥Õ¥§¥¹¥È¥Õ¥¡¥¤¥ë¡ÊAndroidManifest.xml¡Ë¤ËÅÀÀþÆâ¤Îµ½Ò¤òÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jp.co.test" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¤³¤³¤«¤é --> <!-- -------------------------------------------------------------------------------- --> <activity android:name=".Sub2Activity" android:label="@string/sub_activity_name"> </activity> <!-- -------------------------------------------------------------------------------- --> <!-- ¢¬¤³¤³¤Þ¤Ç --> <!-- -------------------------------------------------------------------------------- --> </application> </manifest>
¡Ö²èÌÌÁ«°Ü¡×¥Ü¥¿¥ó¤¬²¡²¼¤µ¤ì¤¿¤È¤¤Î½èÍý¤òµ½Ò¤·¤Þ¤¹¡£
src/jp.co.test/MainActivity.java¤ò³«¤¡¢ÅÀÀþÆâ¤Îµ½Ò¤òÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
src/jp.co.test/MainActivity.java¤ò³«¤¡¢ÅÀÀþÆâ¤Îµ½Ò¤òÄɵ¤·¤Æ¤¯¤À¤µ¤¤¡£
public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { ////// Ãæά //////// // ¥Ö¥é¥¦¥¶¡¼¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤È¤ Button browzerButton = (Button) findViewById(R.id.Button2); browzerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse("http://ecnavi.jp/"); intent.setData(uri); startActivity(intent); } }); //-------------------------------------------------------------------------------- //¢¤³¤³¤«¤é //-------------------------------------------------------------------------------- // ²èÌÌÁ«°Ü¥Ü¥¿¥ó¤ò²¡²¼¤·¤¿¤È¤ Button activityButton = (Button) findViewById(R.id.Button3); activityButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(MainActivity.this, SubActivity.class); startActivity(intent); } }); //-------------------------------------------------------------------------------- //¢¬¤³¤³¤Þ¤Ç //------------------------------------------------------------------------------- } }
¤³¤Î¥Ú¡¼¥¸¤Ø¤Î¥³¥á¥ó¥È
ÂçÊѤªÀ¤Ïäˤʤê¤Þ¤¹¡£
»³ºê¤È¸À¤¤¤Þ¤¹¡£
android¤ÎÊÙ¶¯¤Î¤¿¤á¤Ë¡¢¥µ¥ó¥×¥ë¤òÎý½¬¤µ¤»¤Æ¤¤¤¿¤À¤¤¤Æ¤ª¤ê¤Þ¤·¤¿¡£
¤È¤Æ¤â¡¢¤ï¤«¤ê¤ä¤¹¤¤¥µ¥¤¥È¤Ç¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£
android_practice1.zip¤òõ¤·¤Æ¤ª¤ê¤Þ¤·¤¿¤¬¡¢
¤ï¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£
¤ªË»¤·¤¤¤È¤³¤í¡¢À¿¤Ë¤â¤¦¤·¤ï¤±¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢
¤É¤³¤Ë¤¢¤ë¤Î¤«¶µ¤¨¤Æ¤¤¤¿¤À¤±¤Ê¤¤¤Ç¤·¤ç¤«¡£
¤è¤í¤·¤¯¤ª´ê¤¤¤¤¤¿¤·¤Þ¤¹¡£