- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\r
- /*\r
- * Start an activity based on the selection\r
- * the user made\r
- */\r
- Intent intent;\r
- intent = (Intent) parent.getAdapter().getItem(position);\r
- if(intent != null ){\r
- startActivity(intent);
- } else {\r
- Toast toast = Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT);\r
- toast.show();\r
- } \r
- }\r
-\r
- /**\r
- * Used to populate the landing page grid.\r
- * Defined this one right in here as private class\r
- * as it is unlikely that this Adapter can be useful\r
- * anywhere else.\r
- * \r
- * @author Lennart Rosam\r
- *\r
- */\r
- private class LandingScreenAdapter extends BaseAdapter {\r
-\r
- private Context mContext;\r
-\r
- private final Integer[] mLandingScreenIcons = { R.drawable.home,\r
- R.drawable.music, R.drawable.contacts,\r
- android.R.drawable.ic_menu_today,\r
- android.R.drawable.ic_menu_agenda,\r
- android.R.drawable.ic_menu_preferences };\r
-\r
- private final Integer[] mLandingScreenTexts = { R.string.main_files,\r
- R.string.main_music, R.string.main_contacts,\r
- R.string.main_calendar, R.string.main_bookmarks,\r
- R.string.main_settings };\r
-\r
- public LandingScreenAdapter(Context context) {\r
- mContext = context;\r
- }\r
-\r
- public int getCount() {\r
- return mLandingScreenIcons.length;\r
- }\r
-\r
- /**\r
- * Returns the Intent associated with this object\r
- * or null if the functionality is not yet implemented\r
- */\r
- public Object getItem(int position) {\r
- Intent intent = new Intent();\r
- switch (position) {\r
- case 0:\r
- intent.setClass(mContext, FileDisplayActivity.class);\r
- break;\r
- case 5:\r
- intent.setClass(mContext, Preferences.class);\r
- break;\r
- default:\r
- intent = null;\r
- }\r
- return intent;\r
- }\r
-\r
- public long getItemId(int position) {\r
- return position;\r
- }\r
-\r
- public View getView(int position, View convertView, ViewGroup parent) {\r
- if (convertView == null) {\r
- LayoutInflater inflator = LayoutInflater.from(mContext);\r
- convertView = inflator\r
- .inflate(R.layout.landing_page_item, null);\r
-\r
- ImageView icon = (ImageView) convertView\r
- .findViewById(R.id.gridImage);\r
- TextView iconText = (TextView) convertView\r
- .findViewById(R.id.gridText);\r
-\r
- icon.setImageResource(mLandingScreenIcons[position]);\r
- iconText.setText(mLandingScreenTexts[position]);\r
- }\r
- return convertView;
- }\r
- }\r
-\r
- \r
- \r