Project Detail:
package com.android.listview;
Project Name :listView
Target :2.1
activity Name: ListViewActivity.java
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Xml detail : main.xml
///////////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="67dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="110dp"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="88dp"
android:layout_height="fill_parent"
android:layout_weight="1.54"
android:text="test"
android:textSize="20dp" android:textColor="#67ff12" android:background="#aaaaaa"/>
</LinearLayout>
</LinearLayout>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program detail :
ListViewActivity.java
////////////////////////////////////////
public class ListViewActivity extends ListActivity
{
final static ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>();
static{
HashMap<String, Object> row = new HashMap<String, Object>();
row.put("Icon", R.drawable.india); // put india.png/jpg in drawable folder
row.put("Chance", "Flag India Large Style1");
row.put("TeamID", "Albania");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.indiaf); // put indiaf.png/jpg in drawable folder
row.put("Chance", "Flag India Large Style1 ");
row.put("TeamID", "RPA");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.usa); // put usa.png/jpg in drawable folder
row.put("Chance", "Flag USA ");
row.put("TeamID", "Polska :)");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.img); // put img.png/jpg in drawable folder
row.put("Chance", "Immge Gif ");
row.put("img", "test :)");
data.add(row);
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,
data, R.layout.main , new String[] {"Icon","Chance","TeamID"}, new int[] { R.id.imageView1, R.id.textView1});
setListAdapter(adapter);
}
package com.android.listview;
Project Name :listView
Target :2.1
activity Name: ListViewActivity.java
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Xml detail : main.xml
///////////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="67dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="110dp"
android:layout_height="match_parent"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="88dp"
android:layout_height="fill_parent"
android:layout_weight="1.54"
android:text="test"
android:textSize="20dp" android:textColor="#67ff12" android:background="#aaaaaa"/>
</LinearLayout>
</LinearLayout>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program detail :
ListViewActivity.java
////////////////////////////////////////
public class ListViewActivity extends ListActivity
{
final static ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>();
static{
HashMap<String, Object> row = new HashMap<String, Object>();
row.put("Icon", R.drawable.india); // put india.png/jpg in drawable folder
row.put("Chance", "Flag India Large Style1");
row.put("TeamID", "Albania");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.indiaf); // put indiaf.png/jpg in drawable folder
row.put("Chance", "Flag India Large Style1 ");
row.put("TeamID", "RPA");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.usa); // put usa.png/jpg in drawable folder
row.put("Chance", "Flag USA ");
row.put("TeamID", "Polska :)");
data.add(row);
row = new HashMap<String, Object>();
row.put("Icon", R.drawable.img); // put img.png/jpg in drawable folder
row.put("Chance", "Immge Gif ");
row.put("img", "test :)");
data.add(row);
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this,
data, R.layout.main , new String[] {"Icon","Chance","TeamID"}, new int[] { R.id.imageView1, R.id.textView1});
setListAdapter(adapter);
}
No comments:
Post a Comment