コード例 #1
0
  @Override
  public void taskComplete(String data) {
    // Get the list of lessons, and set the title
    lessonList = LessonQuery.parseLessonsList(data);
    this.setTitle(course.getTitle());

    // Check if there are lessons, if there are then display them in a list,
    // otherwise, display a message saying that no lessons were found.
    if (lessonList.size() == 0) {
      setContentView(R.layout.activity_no_lessonlist);
      TextView contentView = (TextView) findViewById(R.id.noLessonListText);
      contentView.setText("No lessons found for this course.");
    } else {
      setContentView(R.layout.activity_lessonslist);
      ArrayAdapter<Lesson> adapter =
          new ArrayAdapter<Lesson>(this, android.R.layout.simple_list_item_1, lessonList);
      ListView listView = (ListView) findViewById(R.id.lessonsListView);
      listView.setAdapter(adapter);
      listView.setOnItemClickListener(
          new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              LessonsListActivity.this.lessonSelected(position);
            }
          });
    }
  }
コード例 #2
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Bundle extras = getIntent().getExtras();
   if (extras != null) {
     String course_title = extras.getString("course_title");
     int course_id = extras.getInt("course_id");
     course = new Course(course_id, course_title);
     LessonQuery.getAllLessons(this, course_id);
   }
   setContentView(R.layout.loading_screen);
 }