xml page:eazy_list
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
< ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
< /ListView>
< /RelativeLayout>
java page: public class MainActivity extends ListActivity
{
String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
"Jupiter", "Saturn", "Uranus", "Neptune","Ceres","Pluto"};
ListView lstv;
private ArrayAdapter listAdapter ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lstv=getListView();
listAdapter = new ArrayAdapter(this,android.R.layout.simple_expandable_list_item_1, planets);
setListAdapter(listAdapter);
}}

Comments
Post a Comment