コード例 #1
0
  void initList() {
    App app = (App) getApplication();
    List<Semester> semesters = app.getDBHelper().getSemesters(app.getUserDB());
    mData.clear();
    for (int i = 0; i < semesters.size(); i++) {
      HashMap<String, Object> map = new HashMap<String, Object>();
      String name = semesters.get(i).name;
      name = (name == null || name.length() == 0) ? "2012年秋季学期" : name;
      map.put("name", name);
      map.put("semester", semesters.get(i));
      mData.add(map);
    }
    SimpleAdapter adapter =
        new MySimpleAdapter(
            this, mData, R.layout.simple_list_item, new String[] {"name"}, new int[] {R.id.title});
    //		SimpleAdapter adapter = new SimpleAdapter(this, array, R.layout.simple_list_item, new
    // String[]{"name"}, new int[]{R.id.title});
    ListView listView = (ListView) findViewById(R.id.user_list);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new MyOnItemClickListener());
    listView.setDivider(null);

    int dimension = (int) getResources().getDimension(R.dimen.home_menu_left_padding);
    listView.setPadding(0, dimension, 0, dimension);
  }
コード例 #2
0
 @Override
 public void onItemClick(AdapterView<?> listView, View arg1, final int position, long arg3) {
   final Semester semester = (Semester) mData.get(position).get("semester");
   final App app = (App) getApplication();
   String semesterName = semester.name;
   if (app.getActiveSemesterId() != semester.id) {
     new AlertDialog.Builder(SemestersActivity.this)
         .setTitle("提示")
         .setMessage("确定将" + semesterName + "设为当前学期?")
         .setPositiveButton(
             "确定",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialoginterface, int i) {
                 app.setActiveSemesterId(semester.id);
                 Map<String, Object> map = new HashMap<String, Object>();
                 map.put("active_semester_id", semester.id);
                 mDataAdapter.updateUser(map, null, null, null, 0);
                 UIUtil.block(SemestersActivity.this);
               }
             })
         .setNegativeButton(
             "取消",
             new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialoginterface, int i) {
                 // 按钮事件
                 dialoginterface.dismiss();
               }
             })
         .show();
   }
 }
コード例 #3
0
 public MySimpleAdapter(
     Context context,
     List<? extends Map<String, ?>> data,
     int resource,
     String[] from,
     int[] to) {
   super(context, data, resource, from, to);
   App app = (App) getApplication();
   localSemesterId = app.getActiveSemesterId();
 }
コード例 #4
0
 public Paint getPaintCourseText() {
   if (paintCourseText == null) {
     paintCourseText = new Paint();
     paintCourseText.setColor(Color.WHITE);
     float size =
         TypedValue.applyDimension(
             TypedValue.COMPLEX_UNIT_SP, 12, App.getInstance().getResources().getDisplayMetrics());
     paintCourseText.setTextSize(size);
     paintCourseText.setAntiAlias(true);
   }
   return paintCourseText;
 }
コード例 #5
0
 public int getSizeFromStyleFile(int fileSize) {
   return ImageHlp.changeToSystemUnitFromDP(App.getInstance(), fileSize / 2);
 }