Skip to content

Instantly share code, notes, and snippets.

@yahyaahrika
Created June 23, 2016 00:01
Show Gist options
  • Save yahyaahrika/3a0059f4bb0d6d18d1595a184cae1c33 to your computer and use it in GitHub Desktop.
Save yahyaahrika/3a0059f4bb0d6d18d1595a184cae1c33 to your computer and use it in GitHub Desktop.
ListView simple Android
String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview, mobileArray);
ListView listView = (ListView) findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
----------------------activity_main.xml---------------------------
<LinearLayout 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"
android:orientation="vertical"
tools:context=".ListActivity" >
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
----------------------end activity_main.xml---------------------------
----------------------start activity_listview.xml---------------------------
<?xml version="1.0" encoding="utf-8"?>
<!-- Single List Item Design -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>
----------------------end activity_listview.xml---------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment