List View in Android

App Engineer

Step 1. create a xml file name as “friend_detail.xml” in layout .

Step 2. Add a list View .

Step 3 . Create a class file in src name as FriendDetail.java .

Step4 . Write following Code in OnCreate method.

final ListView listview = (ListView) findViewById(R.id.listView1);

String[] values = new String[] { “Android”, “iPhone”, “WindowsMobile”,

“Blackberry”, “WebOS”, “Ubuntu”, “Windows7”, “Max OS X”,

“Linux”, “OS/2”, “Ubuntu”, “Windows7”, “Max OS X”, “Linux”,

“OS/2”, “Ubuntu”, “Windows7”, “Max OS X”, “Linux”, “OS/2”,

“Android”, “iPhone”, “WindowsMobile” };

final ArrayList<String> list = new ArrayList<String>();

for (int i = 0; i < values.length; ++i) {

list.add(values[i]);

}

final StableArrayAdapter adapter = new StableArrayAdapter(this,

android.R.layout.simple_list_item_1, list);

listview.setAdapter(adapter);

Step 5. Create a function after onCreate function .

private

View original post 78 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s