基本信息
源码名称:android 骑行助手app源码(记录骑行轨迹)
源码大小:12.91M
文件格式:.zip
开发语言:Java
更新时间:2018-04-03
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 3 元 
   源码介绍
实现了 注册/登陆 以及 记录自己的骑行轨迹,android 4.4 系统测试,有乱码现象,基本功能已实现,具体如下图





package com.gh.admin;

import com.example.bike.MainActivity;
import com.example.bike.R;
import com.gh.adapter.BikeAdapter;
import com.gh.core.BaseActivity;
import com.gh.map.RideMap;
import com.gh.service.DatabaseHelper;
import com.gh.userdao.Brand;
import android.os.Bundle;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class BikeKnow extends BaseActivity implements OnClickListener,OnItemClickListener,OnItemLongClickListener {
	private Button newbrand,selectbrand,knowback;//新建品牌 查找品牌
	private ListView brandlist;//品牌列表
	
	private DatabaseHelper helper;//创建、管理数据库
	private BikeAdapter adapter;//适配器
	
	public static String userOrAdmin;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_knowledge);
		
		allActivity.add(this);//管理所有Activity 退出时关闭所有Activity
		initViews();
		helper = new DatabaseHelper(this);
		showListView();
	}
	/*
	 * 初始化组件
	 */
	private void initViews() {
		newbrand = (Button) findViewById(R.id.newbrand);
		newbrand.setOnClickListener(this);
		selectbrand = (Button) findViewById(R.id.selectbrand);
		selectbrand.setOnClickListener(this);
		knowback = (Button) findViewById(R.id.knowback);
		knowback.setOnClickListener(this);
		brandlist = (ListView) findViewById(R.id.brandlist);
		brandlist.setOnItemClickListener(this);
		brandlist = (ListView) findViewById(R.id.brandlist);
		brandlist.setOnItemLongClickListener(this);
		if(!userOrAdmin.equals("admin")){
			newbrand.setEnabled(false);
		}
		
	}
	
	/*
	 * 点击事件监听方法 
	 */
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.newbrand:
			Intent intent = new Intent(BikeKnow.this,NewBrand.class);
			NewBrand.userOrAdminNew = userOrAdmin;
			intent.setFlags(MyConfig.REQUEST_CODE_NEW_BRAND);//请求
			startActivityForResult(intent, MyConfig.REQUEST_CODE_NEW_BRAND);
			break;
		
		case R.id.selectbrand:
			showDialog();
			break;
		case R.id.knowback:
			if(!userOrAdmin.equals("admin")){
				Intent intentback = new Intent(BikeKnow.this,RideMap.class);
				startActivity(intentback);
				finish();
			}else{
			Intent intentback1 = new Intent(BikeKnow.this,MainActivity.class);
			startActivity(intentback1);
			finish();
			}
			
		}
	}

	public void showDialog(){
		AlertDialog.Builder custom = new AlertDialog.Builder(this);
		
		custom.setTitle("请输入要查找的内容:");
		custom.setIcon(android.R.drawable.ic_menu_search);
		// 加载自定义的布局
		View view = LayoutInflater.from(this).inflate(R.layout.custom, null);//自定义文本输入框
		custom.setView(view);
		// 获得自定义布局上的控件
		final EditText select = (EditText) view.findViewById(R.id.select);//空指针异常
		
		custom.setPositiveButton("确定",new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						adapter.resetBrandsquery(select.getText().toString());
						
					}
				});
		custom.setNegativeButton("取消", null);
		// 给对话框设置view
		custom.create().show();
		
	}
	private void showListView() {
		adapter = new BikeAdapter(this);
		brandlist.setAdapter(adapter);     //调用方法实现ListView
	}
	//2015-6-6
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Brand brand = (Brand) parent.getAdapter().getItem(position);
		Intent intent = new Intent(this,NewBrand.class);
		NewBrand.userOrAdminNew = userOrAdmin;
		intent.setFlags(MyConfig.REQUEST_CODE_SEE_BRAND);//查看品牌
		intent.putExtra("brand", brand);	//键,值
		startActivityForResult(intent, MyConfig.REQUEST_CODE_SEE_BRAND);   //有返回值的启动activity
	}
	
	@Override
	public boolean onItemLongClick(AdapterView<?> parent, View view,
		int position, long id) {
		
		if(userOrAdmin.equals("admin")){
			Brand brand= (Brand) parent.getAdapter().getItem(position);
			showDeleteDialog(brand.getId());
			adapter.update();
		}else if(userOrAdmin.equals("admin")){
			showUserDialog();
		}
		return false;	//true会调用onItemClick
		
	}
	private void showUserDialog(){
		AlertDialog.Builder dialog = new AlertDialog.Builder(this);
		dialog.setTitle("提示");
		dialog.setMessage("用户不能操作!");
		dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
			}
		});
		dialog.setNegativeButton("返回", null);
		dialog.show();
	}
	private void showDeleteDialog(final int id) {
		AlertDialog.Builder dialog = new AlertDialog.Builder(this);
		dialog.setTitle("删除提示");
		dialog.setMessage("确定要删除该条笔记?");
		dialog.setPositiveButton("删除", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				helper.deleteBrandById(id);
				adapter.resetNotes();
				showListView();
			}
		});
		dialog.setNegativeButton("取消", null);
		dialog.show();
	}
	
	//返回结果
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		adapter.resetNotes();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
	

}