This document provides instructions for a sample Android project called Mark-8. It describes two screens: Screen 1 displays an image and information and links to Screen 2; Screen 2 accepts user input to update the information from Screen 1. It also describes adding a menu with options for Call, SMS, and Exit. The SMS option opens a dialog screen. Finally, it provides instructions for adding a grid view with images and opening a new activity when an item is selected.
4. Screen 1 :
Displays both image and its information.
A link that passes and opens SCREEN 2. Changes
from screen 2 must be captured and updates the
displayed information for whatever changes from
screen 2.
Screen 2 :
Accepts input from user that corresponds
the information from SCREEN 1. All fields must be
correctly filled , if not user must be informed.
Saving changes will end activity and pass data to
screen 1. Cancelling activity will simply closes the
screen and displays previous screen.
5.
6.
7. Option Menu :
Create an XML menu file that contains 3 items : Call, SMS
and Exit
Override onCreateOptionsMenu inside the activity:
@Override
public boolean onCreateOptionsMenu (Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.image_details_menu, menu);
return true;
}
Handle selected item :
@Override
public boolean onOptionsItemSelected (MenuItem item) {
switch(item.getItemId())
{
case R.id.call:
callContact();
break;
}
return true;
}
SMS option opens SCREEN #3 as dialog.
8.
9. Create an XML menu file that declare GridView alone.
Create new class that:
- extend BaseAdapter
- accepts context as parameter
- initialies an array of integer for image resources
- return image as object for image getter
- returns View :
@Override
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(100, 100));
return imageView;
}
Open new activity when item is selected.
Exit as Option menu