《APP》团队冲刺第二阶段 九

    团队昨天优化了计时功能界面之后,感觉相比原来的界面没管了不少,这是第二次冲刺阶段目前为止最成功的的部分,之前两天解决闪退问题的计划还是没能够实现,而且我们仪式也不能解决问题,所以我们打算加入冲刺开始的时候番茄任务的功能。

    《APP》团队冲刺第二阶段 九

 

public class MySqlite extends MainActivity{

private static final String TABALENAME = "student";
    private ListView mListView;
    private List<StudentEntity> mList;
    private MyOpenHlper myOpenHlper;
    private SQLiteDatabase db;
    private Cursor mCursor;
    private SimpleCursorAdapter adapter;
    private int index = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mysqlite);
init();
downLoadData();
}

public void init(){
mListView = (ListView) findViewById(R.id.listView);
mList = new ArrayList<>();
myOpenHlper = new MyOpenHlper(this,"test.db",2);
db = myOpenHlper.getWritableDatabase();
mCursor = db.rawQuery("select * from "+TABALENAME,null);
adapter = new SimpleCursorAdapter(this,android.R.layout.simple_list_item_2, mCursor,
                new String[]{"name","age"},
                new int[]{android.R.id.text1,android.R.id.text2},
SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
mListView.setAdapter(adapter);
}
public void downLoadData(){
mList.add(new StudentEntity("张三",12));
mList.add(new StudentEntity("李四",15));
mList.add(new StudentEntity("王五",18));
mList.add(new StudentEntity("赵六",22));
mList.add(new StudentEntity("麻子", 25));
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main,menu);
        return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
        if(id == R.id.insert_item){
if(index<mList.size()){
                ContentValues values = new ContentValues();
values.put("name",mList.get(index).getName());
values.put("age",mList.get(index).getAge());
db.insert(TABALENAME,null,values);
mCursor = db.rawQuery("select * from "+TABALENAME,null);
adapter.swapCursor(mCursor);
index++;
}
        }
return true;
}

/*  public void btnClick(View view){

        if(index<mList.size()){
            ContentValues values = new ContentValues();
            values.put("name",mList.get(index).getName());
            values.put("age",mList.get(index).getAge());
            db.insert(TABALENAME,null,values);
            mCursor = db.rawQuery("select * from "+TABALENAME,null);
            adapter.swapCursor(mCursor);
            index++;
        }
    }*/
}

 

上一篇:RecyclerView详解(一)


下一篇:ShouYeActivity