カーソルを使用して SQLite データベースからデータを読み取り、アダプタを使用して listView に表示しています。これは問題なく動作しますが、listView に表示するデータの量を減らしたいと考えています。現時点では、次のように表示されます。
John Smith, 25, Moday, Consultation, Dr. Harley
Jane Doe, 41, Wednesday, Surgery, Dr. Pope
表示したいのは次のとおりです。
John Smith, 25, Mo, Con, Harley
Jane Doe, 41, We, Sur, Pope
基本的に、3 つの文字列を解析したいと考えています。問題は、カーソル アダプターがデータベースの列をコンストラクターの文字列配列として受け取るため、どこで解析操作を実行すればよいかわかりません。さまざまなオプションを試してみましたが、認識できない列 ID エラーやその他の実行時エラーが発生しています。誰かが私を正しい方向に向けることができますか?
アダプターが作成されるメソッド:
private void fillList() {
Cursor c = db.getApts();
startManagingCursor(c);
String[] from = new String[] {ModuleDB.KEY_AptCode,
ModuleDB.KEY_AptName,
ModuleDB.KEY_AptAge,
ModuleDB.KEY_AptDay,
ModuleDB.KEY_AptType,
ModuleDB.KEY_AptDoc};
int[] to = new int[] {R.id.Aptcode_entry,
R.id.AptName_entry,
R.id.AptAge_entry,
R.id.Aptday_entry,
R.id.Apttype_entry,
R.id.Aptdoc_entry};
SimpleCursorAdapter aptAdapter =
new SimpleCursorAdapter(this, R.layout.apt_entry, c, from, to);
setListAdapter(aptAdapter);
}