Back to project page androidui.
The source code is released under:
MIT License
If you think the Android project androidui 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 course.examples.UI.ListLayout; /* www . j a v a2 s.co m*/ import android.app.ListActivity; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class ListViewActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create a new Adapter containing a list of colors // Set the adapter on this ListActivity's built-in ListView setListAdapter(new ListViewAdapter( this, R.layout.list_item, getResources().getStringArray(R.array.colors))); // Enable filtering when the user types in the virtual keyboard getListView().setTextFilterEnabled(true); // Set an setOnItemClickListener on the ListView getListView().setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView textView = (TextView) view.findViewById(R.id.text); // Display a Toast message indicting the selected item Toast.makeText(ListViewActivity.this, textView.getText(), Toast.LENGTH_SHORT).show(); } }); } }