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


Android¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤·¡¢¥ê¥¹¥È¥Ó¥å¡¼¤ò»È¤Ã¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£

񂫪1

¹àÌÜÀßÄêÆâÍÆ
¥×¥í¥¸¥§¥¯¥È̾practice_listview_pref
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥ÈAndroid 2.2
¥¢¥×¥ê¥±¡¼¥·¥ç¥ó̾listview_pref
¥Ñ¥Ã¥±¡¼¥¸Ì¾jp.co.example.listview
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£Ì¾ListviewPrefActivity
ºÇ¾®SDK¥Ð¡¼¥¸¥ç¥ó8
¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲä˥Á¥§¥Ã¥¯

¥ì¥¤¥¢¥¦¥È¤ò¼¡¤ÎÆâÍƤ˽ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
	android:layout_height="fill_parent"
	android:layout_width="wrap_content"
¡¡¡¡¡¡¡¡ android:background="#FF909090">
	<!-- ¥ê¥¹¥È¥Ó¥å¡¼ -->
	<ListView
		android:id="@android:id/list"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content" />
	<!-- ¥ê¥¹¥È¤¬¶õ¤Î¤È¤­¤Ëɽ¼¨ -->
	<TextView
		android:id="@android:id/empty"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content" />
</LinearLayout>
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ò¼¡¤ÎÆâÍƤ˽ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£
public class ListviewPrefActivity extends ListActivity {
	/** Called when the activity is first created. */
	private ArrayAdapter<String> mAdapter;
	private static final String[] VIEW_LIST_ITEMS = { "Ë̳¤Æ»", "ÀÄ¿¹¸©", "´ä¼ê¸©", "µÜ¾ë¸©", "½©Åĸ©", "»³·Á¸©",
            "Ê¡Å縩", "°ñ¾ë¸©", "ÆÊÌÚ¸©", "·²Çϸ©", "ºë¶Ì¸©", "ÀéÍÕ¸©", "ÅìµþÅÔ", "¿ÀÆàÀ", "¿·³ã¸©",
            "ÉÙ»³¸©", "ÀÐÀ", "Ê¡°æ¸©", "»³Íü¸©", "ĹÌ", "´ôÉ츩", "ÀŲ¬¸©", "°¦Ãθ©", "»°½Å¸©",
            "¼¢²ì¸©", "µþÅÔÉÜ", "ÂçºåÉÜ", "ʼ¸Ë¸©", "ÆàÎɸ©", "Ï²λ³¸©", "Ä»¼è¸©", "Å纬¸©", "²¬»³¸©",
            "¹­Å縩", "»³¸ý¸©", "ÆÁÅ縩", "¹áÀ", "°¦É²¸©", "¹âÃθ©", "Ê¡²¬¸©", "º´²ì¸©", "Ĺºê¸©",
            "·§Ëܸ©", "Âçʬ¸©", "µÜºê¸©", "¼¯»ùÅ縩", "²­Æ츩" };

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
                // ¥¢¥À¥×¥¿À¸À®
		mAdapter = new ArrayAdapter<String>(
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡getApplicationContext(),
				android.R.layout.simple_list_item_1,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡VIEW_LIST_ITEMS);
                // ¥ê¥¹¥È¥Ó¥å¡¼¤Ë¥¢¥À¥×¥¿¤ò¥»¥Ã¥È
		setListAdapter(mAdapter);
	}

	@Override
        // ¥ê¥¹¥È¤Î¹Ô¤¬¥¯¥ê¥Ã¥¯¤µ¤ì¤¿»þ¤Î½èÍý
	protected void onListItemClick(ListView list, View view, int position, long id) {
                //¡¡¥¯¥ê¥Ã¥¯¤µ¤ì¤¿¹àÌܤò¼èÆÀ¤·¡¢¥È¡¼¥¹¥È¤Ë¤Æɽ¼¨     
		String v = (String) list.getItemAtPosition(position);
		Toast.makeText(getApplicationContext(), v, Toast.LENGTH_SHORT).show();
	}
}
¼Â¹Ô¤¹¤ë¤È¡¢¥ê¥¹¥È¥Ó¥å¡¼¤Ë¤è¤Ã¤Æ¡¢ÅÔÆ»Éܸ©Ì¾¤Î¥ê¥¹¥È¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£

񂫪2

¹àÌÜÀßÄêÆâÍÆ
¥×¥í¥¸¥§¥¯¥È̾practice_listview_add
¥Ó¥ë¥É¥¿¡¼¥²¥Ã¥ÈAndroid 2.2
¥¢¥×¥ê¥±¡¼¥·¥ç¥ó̾listview_add
¥Ñ¥Ã¥±¡¼¥¸Ì¾jp.co.example.listview
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£Ì¾ListviewAddActivity
ºÇ¾®SDK¥Ð¡¼¥¸¥ç¥ó8
¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¥ï¡¼¥­¥ó¥°¥»¥Ã¥È¤Ë¥×¥í¥¸¥§¥¯¥È¤òÄɲä˥Á¥§¥Ã¥¯


¥ì¥¤¥¢¥¦¥È(res/layout/main.xml)¤ò¼¡¤ÎÆâÍƤ˽ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="fill_parent">
  <ListView
     android:id="@android:id/list"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_marginBottom="55dip"
     android:stackFromBottom="true"
     android:transcriptMode="alwaysScroll" />
<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:background="@android:color/transparent"
   android:layout_gravity="bottom">
  <EditText
     android:id="@+id/edit_text"
     android:layout_height="wrap_content"
     android:layout_width="match_parent" 
     android:singleLine="true" 
     android:textSize="15sp"
     android:layout_weight="1"
     android:hint="ÆþÎϤ·¤Æ¤¯¤À¤µ¤¤"/>
  <Button
     android:id="@+id/add_button"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="@string/add_button_label" />
</LinearLayout>
</FrameLayout>
¥ì¥¤¥¢¥¦¥È(res/layout/list_row.xml)¤ò¿·µ¬ºîÀ®¤·¡¢¼¡¤ÎÆâÍƤ˽ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£
<?xml version="1.0" encoding="UTF-8" ?>
<!-- list_row.xml -->
<TextView
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/list_row_text"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:paddingTop="10dip"
   android:paddingBottom="10dip"
   android:textSize="15sp"
   android:textColor="@android:color/black"
   android:background="#7294c1"
   android:text="@string/empty_message" />
res/values/strings.xml¤Ë¡¢¼¡¤ÎÆâÍƤòÄɲ䷤Ƥ¯¤À¤µ¤¤¡£
<resources>
<!-- ¢­¤³¤³¤«¤é¡¡-->
  <string name="empty_message">¥ê¥¹¥È¤¬¶õ¤Ç¤¹</string>
  <string name="add_button_label">ÄɲÃ</string>
<!-- ¢¬¤³¤³¤Þ¤Ç -->
</resources>
¥¢¥¯¥Æ¥£¥Ó¥Æ¥£¤ò¼¡¤ÎÆâÍƤ˽ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡£
public class ListviewAddActivity extends ListActivity {
	ArrayAdapter<String> mAdapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		mAdapter = new ArrayAdapter<String>(getApplicationContext(),
				R.layout.list_row, new ArrayList<String>());
		setListAdapter(mAdapter);

		Button button = (Button) findViewById(R.id.add_button);
		button.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
				inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(),
						0);
				addStringData();
			}
		});
	}

	private void addStringData() {
		EditText edit = (EditText) findViewById(R.id.edit_text);
		mAdapter.add(edit.getText().toString());
		edit.setText("");
	}
}
¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£¥Æ¥­¥¹¥È¥Ü¥Ã¥¯¥¹¤ËÆþÎϤ·¤¿ÆâÍƤ¬¡¢Äɲåܥ¿¥ó²¡²¼»þ¤Ë¥ê¥¹¥È¤ËÈ¿±Ç¤µ¤ì¤Þ¤·¤¿¤«¡£

°Ê¾å¤Ç¡¢ËÜÆü¤Î±é½¬¤Ï½ªÎ»¤Ç¤¹¡£¤ª¤Ä¤«¤ì¤µ¤Þ¤Ç¤·¤¿¡£

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

n3bsso <a href="http://yttjpiulrgcw.com/">yttjpiulrgcw</a>, [url=http://vfjgloqasdzt.com/]vfjgloqasdzt[/url], [link=http://ggwsiynjahqp.com/]ggwsiynjahqp[/link], http://nqintxmozxnu.com/

0
Posted by wldvpseflkx 2013ǯ11·î14Æü(ÌÚ) 13:26:39 ÊÖ¿®

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


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

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

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