bottomLayout.addView(notifyButton, buttonInBottomLayoutParams);
bottomLayout.addView(offlineButton, buttonInBottomLayoutParams);
RelativeLayout.LayoutParams bottomInParentLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
bottomInParentLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
Parent.addView(bottomLayout, bottomInParentLayoutParams);
// 置contentTextView 局
RelativeLayout.LayoutParams contentInParentLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
contentInParentLayoutParams.addRule(RelativeLayout.ABOVE, 10);
Parent.addView(contentTextView, contentInParentLayoutParams);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case 11:
//发起定位请求。请求过程是异步的,定位结果在上面的监听函数onReceiveLocation中获取。
if (mLocationClient != null && mLocationClient.isStarted()) {
mLocationClient.requestLocation();
}else {
Log.e("LocSDK3", "locClient is null or not started");
}
break;
case 12:
//发起POI查询请求。请求过程是异步的,定位结果在上面的监听函数onReceivePoi中获取
if (mLocationClient != null && mLocationClient.isStarted()) {
mLocationClient.requestPoi();
}
break;
case 13:
if (!clickNotify) {
clickNotify = true;
//位置提醒最多提醒3次,3次过后将不再提醒。 假如需要再次提醒,或者要修改提醒点坐标,都可通过函数SetNotifyLocation()来实现
//位置提醒相关代码
mNotifyer = new NotifyLister();
mNotifyer.SetNotifyLocation(42.03249652949337,113.3129895882556,3000,"gps");//4个参数代表要位置提醒的点的坐标,具体含义依次为:纬度,经度,距离范围,坐标系类型(gcj02,gps,bd09,bd09ll)
}else {
clickNotify = false;
//取消位置提醒
mLocationClient.removeNotifyEvent(mNotifyer);
}
break;
case 14:
/*
* 发起离线定位请求。请求过程是异步的,定位结果在上面的监听函数onReceiveLocation中获取。
* getLocTypte = BDLocation.TypteOfflineLocation || BDLocation.TypeOfflineLocationFail
* 表示是离线定位请求返回的定位结果
*/
if (mLocationClient != null && mLocationClient.isStarted()) {
mLocationClient.requestOfflineLocation();
}
break;
}
}
//获取屏幕的宽度,高度和密度以及dp / px
public void getDisplayMetrics() {
DisplayMetrics dm = new DisplayMetrics();
dm = getApplicationContext().getResources().getDisplayMetrics();
Screen_width = dm.widthPixels;
Screen_height = dm.heightPixels;
scale = getResources().getDisplayMetrics().density;
}
public int dip2px(float dpValue) {
return (int)(dpValue * scale + 0.5f);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflat