ListView Example

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

activity_main.xml

This xml shows Textview alone.






MainActivity.java

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.app.ListActivity;
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" };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

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

		ListView listView = getListView();
		listView.setTextFilterEnabled(true);

		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]

p.one {
color: #0000ff;
border: 2px solid;
}
p.two {
color: #00ff00;
outline: 2px solid;
}

[/css]