Beispiel #1
0
  /** initGridViewAdapter */
  private void initGridViewAdapter() {
    mainAdapter = new MainAdapter(this);

    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_calendar),
            R.drawable.desktop_calendar,
            new Intent(getApplicationContext(), CalendarActivity.class)));
    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_documents),
            R.drawable.desktop_documents,
            new Intent(getApplicationContext(), ExplorerActivity.class)));
    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_tasks),
            R.drawable.desktop_tasks,
            new Intent(getApplicationContext(), TaskListActivity.class)));
    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_notices),
            R.drawable.desktop_notices,
            new Intent(getApplicationContext(), NoticeListActivity.class)));
    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_usersinfos),
            R.drawable.desktop_userinfos,
            new Intent(getApplicationContext(), UsersInfoActivity.class)));
    mainAdapter.add(
        new MainItem(
            getString(R.string.menu_settings),
            R.drawable.desktop_preferences,
            new Intent(getApplicationContext(), Sec2PreferenceActivity.class)));

    gridView.setAdapter(mainAdapter);
    gridView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(
              final AdapterView<?> parent, final View view, final int position, final long id) {
            final MainItem item = (MainItem) mainAdapter.getItem(position);
            if (item.intent != null) {
              startActivity(item.intent);
            }
          }
        });
  }