开发者

Hidden Column on ListView - Android

开发者 https://www.devze.com 2023-01-28 11:31 出处:网络
I have several columns from a Database I need to show on a ListView.I also have the ID of the record, but would like to hide that column.

I have several columns from a Database I need to show on a ListView. I also have the ID of the record, but would like to hide that column.

Is there a way to create co开发者_JS百科lumns in the XML for the ListView and maybe hide it there?

UPDATE:

I tried the suggestion from the link in answer 1. This is the code I cam up with but it dumps on the last line.

Does anyone know what I am doing wrong?

 package com.mvw;
 import java.util.ArrayList;
 import java.util.HashMap;
 import android.app.ListActivity;
 import android.os.Bundle;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 import android.widget.SimpleAdapter;

 public class test extends ListActivity {

SimpleAdapter mSchedule;
    ArrayAdapter<String> adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  //  setContentView(R.layout.test);


    ListView list = (ListView) findViewById(R.id.list);

    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();

    HashMap<String, String> map = new HashMap<String, String>();

    map.put("train", "101");
    map.put("from", "6:30 AM");
    map.put("to", "7:40 AM");
    mylist.add(map);

    map = new HashMap<String, String>();
    map.put("train", "103(x)");
    map.put("from", "6:35 AM");
    map.put("to", "7:45 AM");
    mylist.add(map);


    mSchedule = new SimpleAdapter(this, mylist, R.layout.row,
                new String[] {"train", "from", "to"}, new int[] {R.id.TRAIN_CELL, R.id.FROM_CELL, R.id.TO_CELL});

    list.setAdapter(mSchedule);  <--- DUMPS HERE


}
}


Here's a tutorial about making Multi-Column ListViews that may be helpful: http://www.heikkitoivonen.net/blog/2009/02/15/multicolumn-listview-in-android/

0

精彩评论

暂无评论...
验证码 换一张
取 消