{
case R.id.edit:
Intent i = new Intent(context, AddActivity.class);
Note note = DBConnector.select(info.id);
i.putExtra("Note", note);
startActivityForResult (i, UPDATE_ACTIVITY);
updateList();
return true;
case R.id.delete:
DBConnector.delete (info.id);
updateList();
return true;
default:
return super.onContextItemSelected(item);
}
}@Override
public void onPause()
{
super.onPause();if (bitmap != null)
{
bitmap.recycle();
bitmap = null;
}
}@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.add:
Intent add = new Intent(context, AddActivity.class);
startActivityForResult (add, ADD_ACTIVITY);
updateList();
return true;
case R.id.deleteAll:
DBConnector.deleteAll();
updateList();
return true;
case R.id.exit:
finish();
return true;
case R.id.about:
Intent about=new Intent(context, AboutActivity.class);
startActivity(about);
return true;
default:
return super.onOptionsItemSelected(item);
}
}private void updateList ()
{
listAdapter.setArrayNote(DBConnector.selectAll());
listAdapter.notifyDataSetChanged();
}class myListAdapter extends BaseAdapter
{
ArrayList arrayNote;
Bitmap bitmap;
LayoutInflater layoutInflater;
int SizeImage; public myListAdapter (Context ctx, ArrayList arr)
{
layoutInflater = LayoutInflater.from(ctx);
SizeImage = ctx.getResources().getDimensionPixelSize(R.dimen.dimen);setArrayNote(arr);
} public void setArrayNote(ArrayList arrayNote)
{
this.arrayNote = arrayNote;
} public ArrayList getArrayNote()
{
return arrayNote;
}public int getCount ()
{
return arrayNote.size();
}public Object getItem (int position)
{return position;
}
public long getItemId (int position)
{
Note note = arrayNote.get(position);
if (note != null)
{
return note.getID();
}
return 0;
}public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView == null)
convertView = layoutInflater.inflate(R.layout.item, null);ImageView ivImage = (ImageView)convertView.findViewById(R.id.Image);
TextView tvText = (TextView)convertView.findViewById(R.id.Text);
TextView tvDate = (TextView)convertView.findViewById(R.id.Date);Note note = arrayNote.get(position);
tvDate.setText(note.getDate());
tvText.setText(note.getText());
String image = note.getImagePath();
bitmap = Utils.decodeSampledBitmapFromResource(image, SizeImage, SizeImage);
ivImage.setImageBitmap(bitmap);
return convertView;
}
}
}
Дипломный проект выполнен мной совершенно мной самостоятельно, использованные в работе материалы и концепции из опубликованной научной литературы и других источников имеют другие ссылки.
| ||
(Ф.И.О. ) | подпись |
дата |
Похожие работы
Интересная статья: Быстрое написание курсовой работы