ListView Example

The String Array is passed into listview with scroll. A simple and normal way of steps are followed by belowed examples.


This xml shows Textview alone.

This activity shows Array Adapter with String array. Array adapter is used to show the string in listview shape in android. Adapter is must for deliver any output in listview shape.

package com.example.icowboysradio.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends ListActivity {

	static final String[] Countries = new String[] { "India", "Russia", "Japan","China", "Bangladesh", "Srilanka", "Ireland", "Switzerland","Germany", "France", "America", "Brazil", "Colombo" };

	public void onCreate(Bundle savedInstanceState) {

                setListAdapter(new ArrayAdapter(this, R.layout.activity_main, Countries));

		ListView listView = getListView();

		listView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,int position, long id) {

				Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();



Affect of Color Property on Borders and Oulines

The color property is not just for text content, but for anything in the foreground that takes a color value. For instance, if border-color or outline-color value hasn’t been defined explicitly for the element, the color value will be used instead.

[css] {
color: #0000ff;
border: 2px solid;
p.two {
color: #00ff00;
outline: 2px solid;