标签:
移动课堂点名APP
一、源代码地址:https://github.com/WreckBear/final
二、对程序涉及到的以下几个类进行简要说明:
CallNameActivity:显示全局点名的界面。
CallNameAll:负责点名选择界面。
CallNameRdmActivity:负责随机点名界面。
CountActivity:负责统计界面。
ImportActivity:负责导入文件的界面。
MainActivity:主界面。
MoreActivity:更多界面。
MyDBOpenHelper:关于和数据库交互的类。
MyInfoActivity:我的信息页。
PersonDao:关于数据库请求类。
SplashActivity:进入Splash界面。
三、部分代码
贴出统计页面的源码,简要说明下:
1 public class CountActivity extends Activity { 2 ListView listView; 3 TextView text; 4 LinearLayout linearLayout; 5 6 @Override 7 protected void onCreate(Bundle savedInstanceState) { 8 super.onCreate(savedInstanceState); 9 setContentView(R.layout.count_layout); 10 11 text = (TextView) findViewById(R.id.toast); 12 linearLayout = (LinearLayout) findViewById(R.id.instudct); 13 listView = (ListView) findViewById(R.id.count); 14 } 15 16 @Override 17 protected void onStart() { 18 super.onStart(); 19 if (tabIsExist("kecheng1")) { 20 linearLayout.setVisibility(View.VISIBLE); 21 listView.setVisibility(View.VISIBLE); 22 text.setVisibility(View.GONE); 23 count(); 24 } else { 25 linearLayout.setVisibility(View.GONE); 26 listView.setVisibility(View.GONE); 27 text.setVisibility(View.VISIBLE); 28 } 29 } 30 31 public boolean tabIsExist(String tabName) { 32 SQLiteDatabase dbInfo = new MyDBOpenHelper(this).getReadableDatabase(); 33 boolean result = false; 34 if (tabName == null) { 35 return false; 36 } 37 Cursor cursor = null; 38 try { 39 String sql = "select count(*) as c from sqlite_master where type =‘table‘ and name =‘" 40 + tabName.trim() + "‘ "; 41 cursor = dbInfo.rawQuery(sql, null); 42 if (cursor.moveToNext()) { 43 int count = cursor.getInt(0); 44 if (count > 0) { 45 result = true; 46 } 47 } 48 } catch (Exception e) { 49 // TODO: handle exception 50 } finally { 51 dbInfo.close(); 52 } 53 return result; 54 } 55 56 private void count() { 57 // 存放数据用 58 List<HashMap<String, String>> all = new ArrayList<HashMap<String, String>>(); 59 PersonDao per = new PersonDao(this); 60 List<String[]> tmpList = per.getAllPerson(); 61 for (String[] tmpAll : tmpList) { 62 HashMap hash = new HashMap<String, String>(); 63 hash.put("学号", tmpAll[0]); 64 hash.put("班级", tmpAll[3]); 65 hash.put("姓名", tmpAll[1]); 66 hash.put("缺勤", tmpAll[4]); 67 all.add(hash); 68 } 69 SimpleAdapter simple = new SimpleAdapter(this, all, R.layout.liststyle, 70 new String[] { "学号", "班级", "姓名", "缺勤" }, new int[] { R.id.t1, 71 R.id.t2, R.id.t3, R.id.t4 }); 72 listView.setAdapter(simple); 73 74 } 75 }
标签:
原文地址:http://www.cnblogs.com/liuxu8257/p/4576007.html