0

好的,所以我认为我做对了..但它不会编译:类扩展 ListActivity。我试图从列表中提取字符串,以便将其带到捆绑包中的下一个意图,但首先我需要查看是否可以从列表中获取字符串数据

编辑:感谢 Dhaval Sodha Parmar 的帮助,但我还有另一个难题
是否可以动态设置背景?我没有布局,因为只有列表。/编辑

SetUp setup = new SetUp(this);
List<String> characters = new ArrayList<String>();
public String item = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setup.open();
    setup.charList(characters);
    setup.close();

     setListAdapter(new ArrayAdapter<String>(SelectCharacter.this,
     android.R.layout.simple_list_item_1, characters)); 
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);
    item = characters[position];
}

该列表是从数据库创建的:

public void charList(List<String> result)
{
    String[] columns = new String[] { KEY_NAME };
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);

    int iName = c.getColumnIndex(KEY_NAME);

    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
    {
        result.add(c.getString(iName));
    }

} 
4

0 回答 0