滚动时listview的Sqlite android崩溃适配器

时间:2016-07-12 18:18:36

标签: android sqlite listview crash

我有一个适用于ListView的适配器,我在那里收取与匹配的arraylist匹配的数据并进入适配器

我选择一个"团队"在cod_team中找到匹配中的cod_teamhome,但得到团队的名称。

当我获得团队名称时,问题是当我滚动到ListView崩溃时。任何想法,因为崩溃?

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            // inflate the layout
            LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
            convertView = inflater.inflate(layoutResourceId, parent, false);
        }
        Match match = data.get(position);

        TextView textViewHome = (TextView) convertView.findViewById(R.id.teamHome);

        Team teamHome = new Team();

        /+++ CRASH IN THE NEXT LINE +++/
        teamHome = dbHelper.getTeam(match.getCod_teamhome());

        textViewHome.setText(teamHome.getNom_equipo());

获取Sqlite团队的名称:

public Team getTeam(long team_id) {
        SQLiteDatabase db = this.getReadableDatabase();

        String selectQuery = "SELECT  * FROM teams WHERE cod_team = " + team_id;

        Log.e(LOG, selectQuery);
        Cursor c = db.rawQuery(selectQuery, null);

        if (c != null)
            c.moveToFirst();

        Team team = new Team();
        team.setCod_team(c.getInt(c.getColumnIndex(cod_team)));  

        team.setName_Team(c.getString((c.getColumnIndex(nameteam))));
        return team;
    }

Sqlite DATABASE:

  

匹配(cod_match,cod_teamhome,cod_teamvisitor,goals_home,   goal_visitor),当cod_match是主键时

     

团队(cod_team,nameteam),当cod_team是主键时

日志:

  

无法分配CursorWindow   ' /数据/数据/应用/数据库/数据库名称'尺寸2097152由于错误   -12

     

android.database.CursorWindowAllocationException:光标窗口   分配2048 kb失败。 #Outle Cursors = 553(#游标打开   这个proc = 553)

0 个答案:

没有答案