Skip to content

Instantly share code, notes, and snippets.

@Ginny
Created April 24, 2012 17:01
Show Gist options
  • Save Ginny/2481484 to your computer and use it in GitHub Desktop.
Save Ginny/2481484 to your computer and use it in GitHub Desktop.
Listview without extending ListActivity because of actionbar
public class HomeActivity extends MyActionBar {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<String> events = new ArrayList<String>();
events.add("Birthday party");
events.add("Epic party");
events.add("Beach BBQ");
ListView lv = (ListView) findViewById(R.layout.list);
lv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, events));
}
}
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment