i want to change the style of textview of group and child item in ExpandableListView , but it doesn't work .
in the creating adapter first text view will be (lblListHeader ) and second will be (lblListItem )
mAdapter = new HadithExpandableListAdapter(mGroupsCursor, this,
R.layout.drawer_list_ahadith, R.layout.drawer_list_ahadith,
new String[] { "ChapterName" },
new int[] { R.id.lblListHeader }, new String[] { "HadithTitel" },
new int[] { R.id.lblListItem });
in the layout this is file which contain two textview
<?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="55dip"
android:orientation="vertical" >
<TextView
android:id="#+id/lblListItem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17dip"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
<TextView
android:id="#+id/lblListHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17dip"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
</LinearLayout>
Related
I am using Simple Cursor Adapter to generate views in the adapter.The below is the code to generate views.
String[] from = new String []
{DatabaseHelper.COLUMN_CATEGORY,DatabaseHelper.COLUMN_TASKNAME,DatabaseHelper.COLUMN_CROSSED};
int[] to = new int[] {android.R.id.text1, android.R.id.text2, android.R.id.content};
adapter = new SimpleCursorAdapter(context, R.layout.item_todo, data, from, to,1);
lv.setAdapter(adapter);
I am getting the below error.
android.widget.RelativeLayout is not a view that can be bounds by this SimpleCursorAdapter
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dip"
android:paddingTop="10dip" >
<ImageView
android:id="#android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" />
<TextView
android:id="#android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#android:id/icon"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#android:id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#android:id/text1"
android:layout_toRightOf="#android:id/icon"
android:textAppearance="?android:attr/textAppearanceSmall" />
I'm developing an application with ListView for Student Marklist creation.
In this application, the List have 10 students. There are four grades provided for the exam which was conducted to those Students. One student can adapt only one grade from the four.
The teacher will assign the grade to the student in ListView.
My xml file Studentlist.xml is as follow:
<?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" >
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
and my row.xml file is as follow:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="500dp"
android:layout_height="fill_parent"
android:padding="10dp" >
<TableRow>
<TextView
android:id="#+id/SNo"
style="#style/text"
android:layout_width="40dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/StudNo"
style="#style/text"
android:layout_width="80dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/StudName"
style="#style/text"
android:layout_width="180dp"
android:layout_height="wrap_content" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:checked="true" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="40dp"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio2"
android:layout_width="40dp"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/radio3"
android:layout_width="40dp"
android:layout_height="wrap_content" />
</RadioGroup>
</TableRow>
Now I'm trying for the output in the form of:
1 0001 AAAA <RadioButton1> <RadioButton2> <RadioButton3> <RadioButton4>
2 0002 BBBB <RadioButton1> <RadioButton2> <RadioButton3> <RadioButton4>
How can I use the Adapter functionalities?
ArrayAdapter<String,String,String,RadiGroup> studList=new ArrayAdapter<String,String,String,RadiGroup>();
Can I use like this, and how to develop the customized Adapter for the ListView?
Suggest me for the best solution!
This is a sample example of custom adapter for listview. Modify it as your need:
XML layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="#+id/main"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Header -->
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black" >
<TextView
android:id="#+id/item2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:height="30dip"
android:text="Latest News - Your Healing Place"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:width="100dip" />
<TextView
android:id="#+id/item1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:height="30dip"
android:width="20dip" />
</LinearLayout>
<View android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<LinearLayout android:id="#+id/layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<ListView
android:id="#+id/listview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/black" >
</ListView>
</LinearLayout>
</LinearLayout>
news.java :
List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
String[] from = new String[] {"details", "date"};
int[] to = new int[] { R.id.item1, R.id.item2};
ListView lv= (ListView)findViewById(R.id.listview);
HashMap<String, String> map = new HashMap<String, String>();
map.put("details", "This is a sample message");
map.put("date", "24-07-2003");
fillMaps.add(map);
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to);
lv.setAdapter(adapter);
You can use a class inheriting from ArrayAdapter, and overriding its getView() method.
public class StudentAdapter extends ArrayAdapter<Student> {
protected LayoutInflater inflater;
public StudentAdapter(final Context context) {
super(context, 0);
inflater = (LayoutInflater) ((Context) context)
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public View getView(int position, View convertView, ViewGroup parent) {
// Note: You should optimize here with re-using convertView
View rowView = inflater.inflate(R.layout.user_address_row_layout,
parent, false);
TextView sNo = (TextView) rowView.findViewById(R.id.sNo);
sNo.setText(getItem(position).number);
// same for every field of the row
// ...
return rowView;
}
}
I am trying to create search activity. The layout contains EditText (to type search query) Button & ListView (to show search results). search_layout.xml (For showing searchbox & ListView) is as follow :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="#+id/editText_search"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/search_practice" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_search"
android:onClick="searchPractice" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/praclist"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>
And layout for list items list_items.xml is :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Name Label -->
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#43bd00"
android:textSize="16sp"
android:textStyle="bold"
android:paddingTop="6dip"
android:paddingBottom="2dip" />
<!-- Description label -->
<TextView
android:id="#+id/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:paddingBottom="2dip">
</TextView>
<TextView
android:id="#+id/email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:paddingBottom="2dip">
</TextView>
<!-- Linear layout for cost and price Cost: Rs.100 -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- Cost Label -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#5d5d5d"
android:gravity="left"
android:textStyle="bold"
android:text="Phone: " >
</TextView>
<!-- Price Label -->
<TextView
android:id="#+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#acacac"
android:textStyle="bold"
android:gravity="left">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
On button click (searchBtnClick) I am calling method doMySearch :
public void searchBtnClick(View view){
-------
------
ListAdapter adapter = doSearch(query);
ListView pracListView = (ListView) findViewById(R.id.praclist);
PracListView.setAdapter(adapter);
return;
}
private ListAdapter doSearch(String query){
ListAdapter adapter = null;
String url = "https://mywebservice.com/apps/api/v1/search/practices?val="+query+"&by=nam";
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet(url);
String jsonResponsse = null;
try{
HttpResponse httpResponse = httpClient.execute(httpGet, localContext);
HttpEntity httpEntity = httpResponse.getEntity();
jsonResponsse = getASCIIContentFromEntity(httpEntity);
Gson gson = new Gson();
PracticesByName practicesByName = gson.fromJson(jsonResponsse,PracticesByName.class);
ArrayList<Practices> practiceList = (ArrayList<Practices>)practicesByName.getPractices();
for(int i=0 ; i < practiceList.size() ; i ++){
Object a = practiceList.get(i);
System.out.println(a.getClass() + " " + a.toString());
Practices aPractice = practiceList.get(i);
HashMap<String, String> aMap = new HashMap<String, String>();
aMap.put(TAG_NAME, aPractice.getName());
aMap.put(TAG_CITY, aPractice.getCity());
aMap.put(TAG_EMAIL, aPractice.getEmail());
aMap.put(TAG_PHONE, aPractice.getPhone());
searchResultList.add(aMap);
}
adapter = new SimpleAdapter(this, searchResultList,
R.layout.list_item_prac_search,
new String[] { TAG_NAME, TAG_CITY, TAG_EMAIL, TAG_PHONE}, new int[] {
R.id.name, R.id.city, R.id.email, R.id.phone});
//pracListView.setAdapter(adapter);
}catch (Exception e){
System.out.println("Exception while getting serach for practice");
e.printStackTrace();
}
return adapter;
}
The code is running fine. I am getting search result from web service. But don't see any list below. Any idea what I am messing up?
You should first create an array lis to fetch the recorde from the query,
ArrayList<String> items = new ArrayList<String>();
items.add(doSearch(query));
Then replace this line,
ListAdapter adapter = doSearch(query);
with this line,
ArrayAdapter<String> adapter= new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,items);
ListView pracListView = (ListView) findViewById(R.id.praclist);
PracListView.setAdapter(adapter);
Finally, Got it working. Corrected search_layout.xml as follow.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="#+id/editText_search"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/search_practice"
android:imeOptions="actionDone" />
<Button
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="#string/button_search"
android:onClick="searchPractice" />
</LinearLayout>
<ListView
android:id="#+id/praclist"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
making outer layout vertical & placing horizontal layout (containing EditText & Search Button in it) and ListView in it.
Thanks for your time.
my app needs to display data in a list, I walked through some tutorials and figured out to use a header.xml and row.xml. It works fine but now I would like to add more stuff on my header.xml and I found out that the entire header.xml is scrolling with the row.xml as well, which I dont really want.
Any solution that doesn't require me to rewrite and change my code style completely?
Activity:
public class HistoryActivity extends ListActivity
{
private static final String TAG = "HistoryActivity";
ListView lv;
SimpleAdapter sd;
RecordDAO dao = new RecordDAO(HistoryActivity.this);
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
lv = getListView();
lv.addHeaderView(getLayoutInflater().inflate(
R.layout.header, null, false));
}
#Override
protected void onResume()
{
super.onResume();
ArrayList<Record> Records = new ArrayList<Record>();
Records = (ArrayList<Record>) dao.findAll();
ArrayList<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
for (int x = Records.size()-1; x >=0; x--)
{
map = new HashMap<String, String>();
map.put(....// all my data
aList.add(map);
}
sd = new SimpleAdapter(this, aList, R.layout.row,
new String[]
{ "date", "name", "time",
"rating" }, new int[]
{ R.id.date, R.id.name, R.id.time,
R.id.rating});
lv.setAdapter(sd);
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
long arg3)
{
TextView tx = (TextView) view.findViewById(R.id.date);
String s = tx.getText().toString();
Intent intent = new Intent(HistoryActivity.this, EditRecordActivity.class);
intent.putExtra("date", s);
startActivity(intent);
}
});
}
private void insertNewRecord()
{
dao.add(newRecord);
}
}
header.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="name"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Time"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Rating"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</LinearLayout>
</LinearLayout>
row.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:id="#+id/date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="1"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/Rating"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFF" />
</LinearLayout>
Don't use ListActivity. I think it is a bad practice. Use a regular Activity. Just insert a ListView with an id "#android:id/list" into header.xml.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Date"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="name"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Time"
android:textColor="#FFFFFF"
android:textSize="16dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Rating"
android:textColor="#FFFFFF"
android:textSize="16dp" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
And you can get the list reference by doing:
ListView lv = (ListView)findViewById(R.id.list);
Setting the Header of a ListView means that it will be the first item of your list, but still will scroll with the list itself.
In your case, you can create some kind of layout (similar to header.xml) and place it above the ListView.
Instead of ListActivity, extend from Activity
Create a main_layout.xml that define some views and a ListView.
main_layout
<include header.xml/>
<listview>
If you don't want your header and footer views to scroll with your ListView, then make sure that you use the addHeaderView() and addFooterView() BEFORE you call your setAdapter() method. I would recommend moving the setAdapter() method to your onCreate() method.
I have populated a listview(4columns) using simpleadapter and hashmap. Now I would like to have each column of the listview a name.
My listview is displayed inside a linear layout with 4 textviews.
Now, in order to have attribute name of each column, I try to have 2 linear layouts, and the top linear layout have 4 textviews with the attribute names, the bottom linear layout with the data from simpleadapter. And put two linear layouts inside a another linear layout.
And this didn't work the way i want...
I am fairly new to android, please help.
Edit:
Here is my code:
public class MultiList extends ListActivity {
ListView lv;
SimpleAdapter sd;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Calendar c = Calendar.getInstance();
lv = getListView();
ArrayList<HashMap<String, String>> aList = new ArrayList<HashMap<String,String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("Date", ""+c.get(Calendar.DATE));
map.put("Month", ""+c.get(Calendar.MONTH)+1);
map.put("Time", "" + new Date().toString());
aList.add(map);
map = new HashMap<String, String>();
map.put("Date", ""+c.get(Calendar.DATE));
map.put("Month", ""+c.get(Calendar.MONTH)+1);
map.put("Time", "" + new Date().toString());
aList.add(map);
map = new HashMap<String, String>();
map.put("Date", ""+c.get(Calendar.DATE));
map.put("Month", ""+c.get(Calendar.MONTH)+1);
map.put("Time", "" + new Date().toString());
aList.add(map);
sd= new SimpleAdapter(this, aList, R.layout.main, new String[]{"Date","Month","Time"}, new int[]{R.id.studentID,R.id.studentAge,R.id.studentName});
lv.setAdapter(sd);
// insertData();
}
My main.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student ID" />
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student Age" />
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student Name" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:id="#+id/studentID"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/studentAge"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/studentName"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
The problem is, each of the attribute name (student ID, student Age, Student Name) is repeated on every row. How do I fix that?
Break your layout into two, the first one will have the column headers. Let's call it header.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student ID" />
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student Age" />
<TextView
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="student Name" />
</LinearLayout>
The second one is simply for each row, called row.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linear1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:id="#+id/studentID"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/studentAge"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="#+id/studentName"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
(You can give them better names later.)
Now your onCreate() should have this:
// Set up your header
lv.addHeaderView(getLayoutInflater().inflate(R.layout.header, null, false));
// Change the resource id to R.layout.row
sd = new SimpleAdapter(this, aList, R.layout.row, new String[]{"Date","Month","Time"}, new int[]{R.id.studentID,R.id.studentAge,R.id.studentName});
lv.setAdapter(sd);