Back to project page lists.
The source code is released under:
GNU General Public License
If you think the Android project lists listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.cs4730.ListDemo; // w w w .jav a 2 s. c o m /* * much of this code was adapted from * http://www.vogella.de/articles/AndroidListView/article.html * */ import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.util.Log; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class Simple_fraglist extends ListFragment { String TAG = "Simple_frag"; Context myContext; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); String[] values = new String[] { "Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, values); setListAdapter(adapter); } @Override public void onListItemClick(ListView l, View v, int position, long id) { String item = (String) getListAdapter().getItem(position); Toast.makeText(myContext, item + " selected", Toast.LENGTH_LONG).show(); } @Override public void onAttach(Activity activity) { super.onAttach(activity); myContext = activity.getApplicationContext(); Log.d(TAG,"onAttach"); } }