MatrixCursor和listview的用法

    
        protected void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.message_template_list);

        ListView lvTitle = (ListView)findViewById(R.id.listViewTitle);
        MatrixCursor curTitle = new MatrixCursor(new String[] {"_id","title","summary"});
        Object[] obj = {0,this.getString(R.string.title_new_message_template),
                  getString(R.string.summary_new_message_template)};
        curTitle.addRow(obj);

        ListAdapter adapterTitle = new SimpleCursorAdapter(this,
                android.R.layout.simple_list_item_2,
                curTitle,
                new String[] {"title","summary"},
            new int[] {  android.R.id.text1, android.R.id.text2});
        lvTitle.setAdapter(adapterTitle);
        lvTitle.setOnItemClickListener(mNewSmsTemp);
        }

你可能感兴趣的:(Android)