目录
源码下载:
功能预览
编辑
一、项目介绍
二、运行环境
三、部分代码
1:添加活动
2:查看活动
四、更多Android课程设计
五、注意事项
六、源码获取
功能预览
一、项目介绍
管理员功能介绍:
1:用户登录:用户通过账号信息进行软件的登录
2:数据管理:对活动信息、公告信息进行管理
3:查看选课:查看活动预约人员信息
4:个人信息:用户可以浏览个人信息,以及对密码进行修改;用户功能介绍:
1:注册模块,用户在使用软件前需要进行用户信息的注册
2:用户登录:用户通过自己的注册信息进行软件的登录
3:活动信息:查看发布的活动信息,以及对自己感兴趣的活动信息进行预约
4:公告信息:用户可以查看发布的公告信息
5:我的预约:查看自己预约的活动信息,以及可以对活动进行评价和取消
6:个人信息:用户可以浏览个人信息,以及对密码进行修改;
二、运行环境
1:软件使用Android stuido进行开发;
2:使用sqlite本地数据库进行数据的存储;3:需要jdk1.7以上
4:使用雷电模拟器或者Androidstuio自带的模拟器进行运行
三、部分代码
1:添加活动
public class CreatActionActivity extends BaseActivity {
// 标题
private TextView mTvTitle;
// 返回
private ImageView mIvBack,guide_image;
private Button mSubmit;
private EditText et1,et2,et3,et4;
private TextView mtvchoice;
private static final int REQUEST_CODE_SCAN_GALLERY = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_box);
initWidget();
initData();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.mIvBack:
finish();
break;
case R.id.mtvchoice:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
TimeSelector timeSelector = new TimeSelector(this, new TimeSelector.ResultHandler() {
@Override
public void handle(String time) {
mtvchoice.setText(time);
}
}, df.format(new Date()), "2030-12-01 23:59");
timeSelector.setMode(TimeSelector.MODE.YMDHM);//显示 年月日时分(默认);
timeSelector.show();
break;
case R.id.mSubmit:
Action box=new Action();
box.setActionTitle(et1.getText().toString());
box.setActionPerson(et2.getText().toString());
box.setActionDate(mtvchoice.getText().toString());
box.setActionAddress(et3.getText().toString());
box.setActionMessgae(et4.getText().toString());
box.setActionImage(imagePath);
box.save();
CustomToast.showToast(this, "添加成功");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
CreatActionActivity.this.finish();
}
}, 1000);
break;
case R.id.guide_image:
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT"
innerIntent.setType("image/*");
startActivityForResult(innerIntent, REQUEST_CODE_SCAN_GALLERY);
break;
}
}
@Override
public void initWidget() {
et1 =(EditText) findViewById(R.id.et1);
et2 =(EditText) findViewById(R.id.et2);
et3 =(EditText) findViewById(R.id.et3);
et4 =(EditText) findViewById(R.id.et4);
et1.setText("读书会活动");
et2.setText("15");
et3.setText("西安市雁塔区");
et4.setText("大雁塔位于唐长安城晋昌坊(今陕西省西安市南)的大慈恩寺内,又名“慈恩寺塔”。唐永徽三年(652年),玄奘为保存由天竺经丝绸之路带回长安的经卷佛像主持修建了大雁塔,最初五层,后加盖至九层,再后层数和高度又有数次变更,最后固定为所看到的七层塔身,通高64.517米,底层边长25.5米。");
mdialog = new LoadingDialog(this, "上传图片...");
mSubmit = (Button) findViewById(R.id.mSubmit);
mIvBack = (ImageView) findViewById(R.id.mIvBack);
mTvTitle = (TextView) findViewById(R.id.mTvTitle);
mTvTitle.setText("添加活动信息");
mIvBack.setVisibility(View.VISIBLE);
mIvBack.setOnClickListener(this);
mSubmit.setOnClickListener(this);
mtvchoice = (TextView) findViewById(R.id.mtvchoice);
mtvchoice.setOnClickListener(this);
guide_image = (ImageView) findViewById(R.id.guide_image);
guide_image.setOnClickListener(this);
}
private int posIndex;
@Override
public void initData() {
}
Uri uriInfor;
String imagePath;
public void onActivityResult(final int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_CODE_SCAN_GALLERY:
uriInfor = data.getData();
imagePath = getRealPathFromUri(this, data.getData());
String cameraPath = imagePath;
Bitmap bitmap = BitmapFactory.decodeFile(cameraPath);
guide_image.setImageBitmap(bitmap);
Log.i("pony_log","imagePath:"+imagePath);
break;
}
}
super.onActivityResult(requestCode, resultCode, data);
}
/**
* 根据图片的Uri获取图片的绝对路径(已经适配多种API)
*
* @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
*/
public static String getRealPathFromUri(Context context, Uri uri) {
int sdkVersion = Build.VERSION.SDK_INT;
if (sdkVersion < 11) {
// SDK < Api11
return getRealPathFromUri_BelowApi11(context, uri);
}
if (sdkVersion < 19) {
// SDK > 11 && SDK < 19
return getRealPathFromUri_Api11To18(context, uri);
}
// SDK > 19
return getRealPathFromUri_AboveApi19(context, uri);
}
/**
* 适配api19以上,根据uri获取图片的绝对路径
*/
private static String getRealPathFromUri_AboveApi19(Context context, Uri uri) {
String filePath = null;
String wholeID = DocumentsContract.getDocumentId(uri);
// 使用':'分割
String id = wholeID.split(":")[1];
String[] projection = {MediaStore.Images.Media.DATA};
String selection = MediaStore.Images.Media._ID + "=?";
String[] selectionArgs = {id};
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection,
selection, selectionArgs, null);
int columnIndex = cursor.getColumnIndex(projection[0]);
if (cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
cursor.close();
return filePath;
}
/**
* 适配api11-api18,根据uri获取图片的绝对路径
*/
private static String getRealPathFromUri_Api11To18(Context context, Uri uri) {
String filePath = null;
String[] projection = {MediaStore.Images.Media.DATA};
CursorLoader loader = new CursorLoader(context, uri, projection, null,
null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
return filePath;
}
/**
* 适配api11以下(不包括api11),根据uri获取图片的绝对路径
*/
private static String getRealPathFromUri_BelowApi11(Context context, Uri uri) {
String filePath = null;
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(uri, projection,
null, null, null);
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
return filePath;
}
}
2:查看活动
public class ActionMessageActivity extends BaseActivity {
// title
private TextView mTvTitle, mIvStu;
// 返回
private ImageView mIvBack;
// 查询按钮
private TextView mtvtitle;
private TextView mtvcontentZhuSu;
private Action sceneryModel;
private TextView mtvtime;
private RelativeLayout mllbottom;
private Button mbtnPay, mbtndelete;
private TextView mtvShopPrice;
private TextView courseLength;
private ImageView guide_image;
private ListviewForScrollView mListMessage;
ScrollView mscview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_projectlistview);
initWidget();
initData();
}
@Override
public void initWidget() {
mscview = (ScrollView) findViewById(R.id.mscview);
mListMessage = (ListviewForScrollView) findViewById(R.id.mListMessage);
guide_image = (ImageView) findViewById(R.id.guide_image);
guide_image.setOnClickListener(this);
mIvStu = (TextView) findViewById(R.id.mIvStu);
mIvStu.setVisibility(View.GONE);
mIvStu.setOnClickListener(this);
mbtnPay = (Button) findViewById(R.id.mbtnPay);
mbtndelete = (Button) findViewById(R.id.mbtndelete);
mbtndelete.setOnClickListener(this);
mllbottom = (RelativeLayout) findViewById(R.id.mllbottom);
mtvcontentZhuSu = (TextView) findViewById(R.id.mtvcontentZhuSu);
mtvtitle = (TextView) findViewById(R.id.mtvtitle);
mIvBack = (ImageView) findViewById(R.id.mIvBack);
mTvTitle = (TextView) findViewById(R.id.mTvTitle);
mTvTitle.setText("详情信息");
mIvBack.setVisibility(View.VISIBLE);
mIvBack.setOnClickListener(this);
mbtnPay.setOnClickListener(this);
mtvShopPrice = (TextView) findViewById(R.id.mtvShopPrice);
}
List<Apply> applyState;
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.mIvBack:
ActionMessageActivity.this.finish();
break;
case R.id.mbtnPay:
if (MemberUserUtils.getType(this).equals("2")){
Action delete = Action.findById(Action.class, sceneryModel.getId());
delete.delete();
ToastUtil.ShowToast(this, "删除成功");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
finish();
}
}, 1000);
}else{
applyState = Apply.findWithQuery(Apply.class, "Select * from Apply where applyUserId = " + MemberUserUtils.getUid(this) + " and actionId= " + sceneryModel.getId());
if (applyState.size() == 0) {
Apply apply = new Apply();
apply.setActionId(sceneryModel.getId());
apply.setActionTitle(sceneryModel.getActionTitle());
apply.setActionPerson(sceneryModel.getActionPerson());
apply.setActionAddress(sceneryModel.getActionAddress());
apply.setActionDate(sceneryModel.getActionDate());
apply.setActionMessgae(sceneryModel.getActionMessgae());
apply.setActionImage(sceneryModel.getActionImage());
apply.setApplyUserId(Long.valueOf(MemberUserUtils.getUid(this)));
apply.setApplyUserName(MemberUserUtils.getName(this));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
apply.setApplyTime(df.format(new Date()));
apply.save();
ToastUtil.ShowToast(this, "预约成功");
} else {
ToastUtil.ShowToast(this, "您已经预约过此活动了");
}
}
break;
case R.id.mbtndelete:
Intent intent = new Intent(this, ApplyUserListActivity.class);
intent.putExtra("msg", sceneryModel);
this.startActivity(intent);
break;
case R.id.mIvStu:
break;
}
}
List<Collect> collectState;
@Override
public void initData() {
sceneryModel = (Action) this.getIntent().getSerializableExtra("msg");
mtvtitle.setText(sceneryModel.getActionTitle());
mtvcontentZhuSu.setText("活动时间:" + sceneryModel.getActionDate() + "\n活动地址:" + sceneryModel.getActionAddress()
+ "\n活动内容:" + sceneryModel.getActionMessgae());
mtvShopPrice.setText(sceneryModel.getActionPerson());
Bitmap bitmap = BitmapFactory.decodeFile(sceneryModel.getActionImage());
guide_image.setImageBitmap(bitmap);
List<Review> listData = Review.findWithQuery(Review.class, "Select * from Review where reviewMessageId = " + sceneryModel.getId());
ReplyAdapter replyAdapter = new ReplyAdapter(this, listData);
mListMessage.setAdapter(replyAdapter);
mscview.smoothScrollTo(0,0);
if (MemberUserUtils.getType(this).equals("2")){
mbtnPay.setText("删除活动");
}else{
mbtnPay.setText("参加活动");
}
}
}