Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void refreshScreen() {
- Call<List<Course>> call = restClient.getService().getCourse();
- call.enqueue(new Callback<List<Course>>() {
- @Override
- public void onResponse(Call<List<Course>> call, Response<List<Course>> response) {
- ListView lv = (ListView) findViewById(R.id.listView);
- ArrayList<HashMap<String, String>> courseList = new ArrayList<HashMap<String, String>>();
- for (int i = 0; i < response.body().size(); i++) {
- HashMap<String, String> course = new HashMap<String, String>();
- if (response.body().get(i).getUserId().equals(Global_config._USER_ID_CUR)) {
- course.put("id", String.valueOf(response.body().get(i).getId()));
- course.put("name", String.valueOf(response.body().get(i).getName()));
- courseList.add(course);
- }
- }
- lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- course_Id = (TextView) view.findViewById(R.id.user_Id);
- courseId = course_Id.getText().toString();
- course_name = (TextView) view.findViewById(R.id.user_name);
- courseName = course_name.getText().toString();
- Intent objIndent = new Intent(getApplicationContext(), CourseManagerActivity.class);
- objIndent.putExtra("course_Id", courseId);
- objIndent.putExtra("course_title", courseName);
- startActivity(objIndent);
- }
- });
- ListAdapter adapter = new SimpleAdapter(TeacherActivity.this, courseList, R.layout.view_user_entry, new String[]{"id", "name"}, new int[]{R.id.user_Id, R.id.user_name});
- lv.setAdapter(adapter);
- }
- @Override
- public void onFailure(Call<List<Course>> call, Throwable t) {
- Toast.makeText(TeacherActivity.this, t.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement