- 浏览: 40329 次
最新评论
-
keshuangjie:
listView.setSelectionFromTop(li ...
Android 记录和恢复ListView滚动的位置( 完美实现 ) -
glaivelee-michele:
scrolledX = listView.getScrollX ...
Android 记录和恢复ListView滚动的位置( 完美实现 )
package com.easecom.zhwg.ctrl.scene.rail; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.PopupWindow; import android.widget.TextView; import android.widget.Toast; import com.baidu.mapapi.BMapManager; import com.baidu.mapapi.GeoPoint; import com.baidu.mapapi.ItemizedOverlay; import com.baidu.mapapi.MKMapViewListener; import com.baidu.mapapi.MapActivity; import com.baidu.mapapi.MapController; import com.baidu.mapapi.MapView; import com.baidu.mapapi.Overlay; import com.baidu.mapapi.OverlayItem; import com.baidu.mapapi.Projection; import com.easecom.widget.OnWheelChangedListener; import com.easecom.widget.OnWheelScrollListener; import com.easecom.widget.WheelView; import com.easecom.widget.adapters.ArrayWheelAdapter; import com.easecom.widget.adapters.NumericWheelAdapter; import com.easecom.zhwg.R; import com.easecom.zhwg.app.WGApp; import com.easecom.zhwg.ctrl.scene.rail.GaoTieClass.RainLineDao; import com.easecom.zhwg.ctrl.scene.rail.GaoTieClass.RainLineService; import com.easecom.zhwg.ctrl.scene.station.ListViewDialogAdapter; import com.easecom.zhwg.util.URLUtil; import com.easecom.zhwg.util.WebUtils; public class RainStation extends MapActivity { // 标题版设置按钮 private TextView top_text; private Button btn_back; private Button btn_info; public static View mPopView; // 点击mark时弹出的气泡View public MapView mMapView;// 地图 private PopupWindow popupWindow;// 指标框 private View view; public MapController mapController; GeoPoint geoPoint; List<Overlay> list; private List<Map<String, String>> n_list; Typeface typeface = null; List<RainLineDao> rainLineDaos = null; ProgressDialog progressDialog; LayoutInflater inflater = null; private WGApp app; private static int nowMapLeave = 1; private Handler handler = new Handler(); // 存放获取的数据 public static List<RainLineDao> mRainLineDao; // 存放获取的2G数据 public static List<RainLineDao> mRainLineDao2G; // 存放获取的3G数据 public static List<RainLineDao> mRainLineDao3G; //筛选基站 判断选择哪个 private int checkIndex=0; // 日期控件使用 private int startYear; private int startMonth; private int startDay; private int endYear; private int endMonth; private int endDay; private String start_time = ""; private String end_time = ""; private int width; private TextView start_timenew; /* * Runnable runnableUi = new Runnable() { * * @Override public void run() { // 更新界面 progressDialog = * ProgressDialog.show(RainStation.this, null,"正在更新数据,请稍后...", true, true); * try { String path = * URLUtil.RAINLINESERVICE+"?netWorkType=&siteABC=&gwNodeName="; new * QueryRain().execute(path); } catch (Exception e) { } * handler.postDelayed(runnableUi, 1000*60*5); } * * }; */ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rain_main); progressDialog = ProgressDialog.show(RainStation.this, null, "正在更新数据,请稍后...", true, true); String path = URLUtil.RAINLINESERVICE + "?netWorkType=&siteABC=&gwNodeName="; new QueryRain().execute(path); QueryRain2G taskTwoG = new QueryRain2G(); String pathTwoG = URLUtil.RAINLINETWOGSERVICE + "?startTime=&endTime=&gwCellName=&gwNodeName="; taskTwoG.execute(pathTwoG); QueryRain3G taskThreeG = new QueryRain3G(); String pathThreeG = URLUtil.RAINLINETHREEGSERVICE + "?startTime=&endTime=&gwCellName=&gwNodeName="; taskThreeG.execute(pathThreeG); inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD); ViewUI(); app = (WGApp) this.getApplication(); if (app.mBMapMan == null) { app.mBMapMan = new BMapManager(getApplication()); app.mBMapMan.init(app.mStrKey, new WGApp.MyGeneralListener()); } app.mBMapMan.start(); // 如果使用地图SDK,请初始化地图Activity super.initMapActivity(app.mBMapMan); mMapView = (MapView) findViewById(R.id.bmapView); mMapView.regMapViewListener(app.mBMapMan, new MyMapViewListener()); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); init(); initPopview(); initLocation(); // initOverlayItem(new ArrayList<RainLineDao>()); // handler.post(runnableUi); } private void ViewUI() { top_text = (TextView) findViewById(R.id.top_text); top_text.setText(""); // 返回按钮 btn_back = (Button) findViewById(R.id.btn_back); btn_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RainStation.this.finish(); } }); btn_info = (Button) findViewById(R.id.btn_info); btn_info.setVisibility(View.GONE); btn_info.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showAtLocation(findViewById(R.id.rain), Gravity.CENTER, 0, 0); } }); // 初始化popupwindow view = LayoutInflater.from(this).inflate(R.layout.zhibiao, null); popupWindow = new PopupWindow(view, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); popupWindow.setAnimationStyle(android.R.style.Animation_Toast); ColorDrawable dw = new ColorDrawable(0xb0000000); popupWindow.setBackgroundDrawable(dw); } /** * 数据解析 * */ class QueryRain extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... params) { Map<String, String> fields = new HashMap<String, String>(); return WebUtils.httpPost(params[0], fields); } @Override protected void onPostExecute(String result) { parJson(result,1); if (null == mRainLineDao) { progressDialog.dismiss(); Toast toast = Toast.makeText(RainStation.this, "暂无信息!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } } } /** * 数据解析2 * */ class QueryRain2G extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... params) { Map<String, String> fields = new HashMap<String, String>(); return WebUtils.httpPost(params[0], fields); } @Override protected void onPostExecute(String result) { parJson(result,2); if (null == mRainLineDao2G) { progressDialog.dismiss(); Toast toast = Toast.makeText(RainStation.this, "暂无信息!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } } } /** * 数据解析3 * */ class QueryRain3G extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... params) { Map<String, String> fields = new HashMap<String, String>(); return WebUtils.httpPost(params[0], fields); } @Override protected void onPostExecute(String result) { parJson(result,3); if (null == mRainLineDao3G) { progressDialog.dismiss(); Toast toast = Toast.makeText(RainStation.this, "暂无信息!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } } } // 获取listview数据 public void parJson(String result,int mdate) { try { System.out.println(":::::::::::::::::::::"+mdate); if(mdate==1){ mRainLineDao = RainLineService.readXML(result); initOverlayItem(mRainLineDao); } else if(mdate==2){ mRainLineDao2G = RainLineService.readXML2G(result); } else if(mdate==3){ mRainLineDao3G = RainLineService.readXML3G(result); } } catch (Exception e) { } } /** * 根据地图缩放级别显示数据 */ public class MyMapViewListener implements MKMapViewListener { @Override public void onMapMoveFinish() { // TODO Auto-generated method stub mMapView.getOverlays().clear(); nowMapLeave = mMapView.getZoomLevel(); if (mRainLineDao != null) { initOverlayItem(mRainLineDao); } } } private void init() { mMapView.setClickable(true); mMapView.setEnabled(true); mMapView.setTraffic(true); mMapView.setBuiltInZoomControls(true); mMapView.setDrawOverlayWhenZooming(true);// 设置在缩放动画过程中也显示overlay,默认为不绘制 mapController = mMapView.getController(); list = mMapView.getOverlays(); mMapView.removeViewAt(1); // 去掉logo } private void initLocation() { mMapView.preLoad(); // geoPoint = LanUtil.getGeoPoint(rpositions);////设置中心点 geoPoint = new GeoPoint((int) (36.60839 * 1e6), (int) (116.99817 * 1e6)); mapController.setZoom(10); if (null != geoPoint) { mapController.setCenter(geoPoint); } } //设置选中的某地名中心点 private void locationCenter(int weiDu ,int jingDu ,int zoom) { mMapView.preLoad(); // geoPoint = LanUtil.getGeoPoint(rpositions);//设置中心点 geoPoint = new GeoPoint( weiDu, jingDu); mapController.setZoom(zoom); if (null != geoPoint) { mapController.setCenter(geoPoint); } } private void initPopview() { // 创建点击mark时的弹出泡泡 mPopView = super.getLayoutInflater().inflate(R.layout.popview, null);// 初始化弹出框 mMapView.addView(mPopView, new MapView.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, null, MapView.LayoutParams.TOP_LEFT)); mPopView.setVisibility(View.GONE); } private void initOverlayItem(List<RainLineDao> mRainLineDao) { if (null != mMapView) { mMapView.getOverlays().clear(); } nowMapLeave = mMapView.getZoomLevel(); Drawable marker = getResources().getDrawable(R.drawable.g_null); // 得到需要标在地图上的资源 marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight()); // 为maker定义位置和边界 mMapView.getOverlays().add( new OverItemT(marker, this, mRainLineDao, nowMapLeave)); // 添加ItemizedOverlay实例到mMapView } @Override protected void onPause() { WGApp app = (WGApp) this.getApplication(); app.mBMapMan.stop(); super.onPause(); } @Override protected void onResume() { WGApp app = (WGApp) this.getApplication(); app.mBMapMan.start(); super.onResume(); } @Override protected boolean isRouteDisplayed() { return false; } // 创建菜单 @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); /*menu.add(0, 1, 0, "多维监控"); menu.add(0, 2, 1, "资源视图"); menu.add(0, 3, 2, "性能视图"); menu.add(0, 4, 3, "数据查询");*/ menu.add(0, 1, 0, "关键指标信息"); menu.add(0, 2, 1, "筛选基站"); return true; } // 菜单点击事件 @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(); switch (item.getItemId()) { case 1: /*intent.setClass(RainStation.this, MonViewActivity.class); startActivity(intent); RainStation.this.finish();*/ intent.setClass(RainStation.this, KeyindexActivity.class); startActivity(intent); break; case 2: MyDialogSearchJiZhan(); /*intent.setClass(RainStation.this, ZiyuanDataActivity.class); startActivity(intent);*/ //new MyDialog(RainStation.this,false).setDisplay(); //MyDialogSearch(); break; case 3: /*intent.setClass(RainStation.this, SceneHistoryplayBack.class); startActivity(intent);*/ break; case 4: /*intent.setClass(RainStation.this, DataFindLookActivity.class); startActivity(intent);*/ break; } return true; } //条件筛选 选择基站名称 private void MyDialogSearchJiZhan(){ Dialog dialog = null; Builder builder = new AlertDialog.Builder(RainStation.this); String[] items = new String[RainStation.mRainLineDao.size()]; if(RainStation.mRainLineDao.size()>0){ for(int i=0;i<mRainLineDao.size();i++ ){ items[i]=mRainLineDao.get(i).getGwnode_name(); } } // Arrays.sort(items); //给Array排序 builder.setTitle("选择指标"); DialogInterface.OnClickListener mutiListener2 = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub checkIndex=which; } }; builder.setSingleChoiceItems(items, -1, mutiListener2); DialogInterface.OnClickListener btnListener2 = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { //获取经纬度 double weiDu = Double.parseDouble(mRainLineDao.get(checkIndex).getWeidu()); int weiDu1=(int) (weiDu * 1E6); double jingDu = Double.parseDouble(mRainLineDao.get(checkIndex).getJingdu()); int jingDu1=(int) (jingDu * 1E6); //经,纬度,缩放级别 locationCenter(weiDu1,jingDu1,15); //显示弹出框 Drawable marker = null; new OverItemT(marker,RainStation.this,mRainLineDao,15).onTap(checkIndex); } }; builder.setPositiveButton("确定", btnListener2); builder.setNegativeButton("取消", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); } //条件筛选 选择基站名称1 private void MyDialogSearch(){ Dialog dialog = null; Builder builder = new AlertDialog.Builder(RainStation.this); ArrayList<String> arrayList = new ArrayList<String>(); String[] items = new String[RainStation.mRainLineDao.size()]; if(RainStation.mRainLineDao.size()>0){ for(int i=0;i<mRainLineDao.size();i++ ){ arrayList.add(mRainLineDao.get(i).getCell_name()); items[i]=mRainLineDao.get(i).getCell_name(); } }else{ } builder.setTitle("选择小区名称"); DialogInterface.OnClickListener mutiListener2 = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }; builder.setSingleChoiceItems(items, -1, mutiListener2); DialogInterface.OnClickListener btnListener2 = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { } }; builder.setPositiveButton("确定", btnListener2); builder.setNegativeButton("取消", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); } /* * @Override protected void onDestroy() { * handler.removeCallbacks(runnableUi); super.onDestroy(); * * } */ // 显示popupwindow public void showAtLocation(View parent, int gravity, int x, int y) { if (null != popupWindow && popupWindow.isShowing()) { popupWindow.dismiss(); } popupWindow.showAtLocation(parent, gravity, x, y); // 使其聚集 popupWindow.setFocusable(true); // 设置允许在外点击消失 // popupWindow.setOutsideTouchable(true); // 刷新状态 popupWindow.update(); } // 隐藏菜单 public void G2event() { } public void dismiss() { popupWindow.dismiss(); } class MyDialog extends Dialog implements View.OnClickListener { private Button button1_date; private Button button2_date; private EditText start_time; private EditText end_time; private Button cancelButton;// 取消按钮 private Button okButton;// 确定按钮 private ListViewDialogAdapter mAdapter; private Context context; public MyDialog(Context context,boolean flag) { super(context); this.context=context; } public void setDisplay() { setContentView(R.layout.rain_dialog);// 设置对话框的布局 button1_date = (Button) findViewById(R.id.button1_date);// 开始日期按钮 button2_date = (Button) findViewById(R.id.button2_date);// 结束日期按钮 start_time = (EditText) findViewById(R.id.start_time);// 开始时间文本框 end_time = (EditText) findViewById(R.id.end_time);// 结束时间文本框 cancelButton = (Button) findViewById(R.id.no_query);// 取消按钮 okButton = (Button) findViewById(R.id.yes_query);// 确定按钮 okButton.setOnClickListener(listener); button1_date.setOnClickListener(listener); button2_date.setOnClickListener(listener); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); setTitle("查询条件");// 设定对话框的标题 start_time.setText(new StringBuilder().append(startYear) .append("-").append(format(startMonth + 1)).append("-") .append(format(startDay)) .append(" ").append("00:00:00")); end_time.setText(new StringBuilder().append(endYear) .append("-").append(format(endMonth + 1)).append("-") .append(format(endDay)) .append(" ").append("23:59:59")); show();// 显示对话框 } private View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { Dialog dialog = null; Builder builder = new AlertDialog.Builder(RainStation.this); switch (v.getId()) { case R.id.button1_date: initstarttime(start_time,1); break; case R.id.button2_date: initstarttime(end_time,2); break; case R.id.yes_query: dismiss(); // progressDialog = ProgressDialog.show(RainStation.this, "请等待...", "正在加载信息,请稍后...",true, true); // String path2 = ""; // try { // path2 = URLUtil.KEYINDEX // + "?startTime="+ URLEncoder.encode(start_time.getText().toString(),"utf-8") // + "&endTime="+ URLEncoder.encode(end_time.getText().toString(),"utf-8") // +"&granularity="; // } catch (UnsupportedEncodingException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // System.out.println("我日开始"+start_time.getText().toString()); // System.out.println("我日结束"+end_time.getText().toString()); // /* 8888888888 此处QueryRain()为假的 88888888888888888888888888*/ // new QueryRain().execute(path2); break; default: break; } } }; private String format(int x) { String s = "" + x; if (s.length() == 1) s = "0" + s; return s; } @Override public void onClick(View v) { } } /** * Updates day wheel. Sets max days according to selected month and year */ void updateDays(WheelView year, WheelView month, WheelView day) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + year.getCurrentItem()); calendar.set(Calendar.MONTH, month.getCurrentItem()); int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); day.setViewAdapter(new DateNumericAdapter(this, 1, maxDays, calendar .get(Calendar.DAY_OF_MONTH) - 1)); int curDay = Math.min(maxDays, day.getCurrentItem() + 1); day.setCurrentItem(curDay - 1, true); } /** * Adapter for numeric wheels. Highlights the current value. */ private class DateNumericAdapter extends NumericWheelAdapter { // Index of current item int currentItem; // Index of item to be highlighted int currentValue; /** * Constructor */ public DateNumericAdapter(Context context, int minValue, int maxValue, int current) { super(context, minValue, maxValue); this.currentValue = current; setTextSize(16); } public DateNumericAdapter(Context context, int minValue, int maxValue, int current, String format) { super(context, minValue, maxValue, format); this.currentValue = current; setTextSize(16); } @Override protected void configureTextView(TextView view) { super.configureTextView(view); if (currentItem == currentValue) { view.setTextColor(0xFF0000F0); } view.setTypeface(Typeface.SANS_SERIF); } @Override public View getItem(int index, View cachedView, ViewGroup parent) { currentItem = index; return super.getItem(index, cachedView, parent); } } /** * Adapter for string based wheel. Highlights the current value. */ private class DateArrayAdapter extends ArrayWheelAdapter<String> { // Index of current item int currentItem; // Index of item to be highlighted int currentValue; /** * Constructor */ public DateArrayAdapter(Context context, String[] items, int current) { super(context, items); this.currentValue = current; setTextSize(16); } @Override protected void configureTextView(TextView view) { super.configureTextView(view); if (currentItem == currentValue) { view.setTextColor(0xFF0000F0); } view.setTypeface(Typeface.SANS_SERIF); } @Override public View getItem(int index, View cachedView, ViewGroup parent) { currentItem = index; return super.getItem(index, cachedView, parent); } } /** * 时间控件 * */ private void initstarttime(final TextView sTextView,final int flag) { LayoutInflater inflater=LayoutInflater.from(this); final View dialog=inflater.inflate(R.layout.date_layout_dialog, null); final Calendar calendar = Calendar.getInstance(); final WheelView day = (WheelView) dialog.findViewById(R.id.day); final WheelView month = (WheelView) dialog.findViewById(R.id.month); final WheelView year = (WheelView) dialog.findViewById(R.id.year); final WheelView hours = (WheelView) dialog.findViewById(R.id.hour); final WheelView mins = (WheelView) dialog.findViewById(R.id.mins); final WheelView seconds = (WheelView) dialog.findViewById(R.id.seconds); AlertDialog.Builder builder=new AlertDialog.Builder(RainStation.this); builder.setTitle("选择时间"); builder.setView(dialog); //关键 builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sTextView.setText(calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-" +((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-" +(day.getCurrentItem() + 1) +" "+hours.getCurrentItem()+":" +((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":" +((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem())); if(flag==1){ start_time=calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-" +((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-" +(day.getCurrentItem() + 1) +" "+hours.getCurrentItem()+":" +((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":" +((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem()); }else if (flag==2) { end_time=calendar.get(Calendar.YEAR) + year.getCurrentItem()+"-" +((month.getCurrentItem()+1<10)?("0"+(month.getCurrentItem()+1)):month.getCurrentItem()+1)+"-" +(day.getCurrentItem() + 1) +" "+hours.getCurrentItem()+":" +((mins.getCurrentItem() < 10) ? ("0" + mins.getCurrentItem()) : mins.getCurrentItem())+":" +((seconds.getCurrentItem() < 10) ? ("0" + seconds.getCurrentItem()) : seconds.getCurrentItem()); } } }); builder.setNegativeButton("取消",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); OnWheelChangedListener listener = new OnWheelChangedListener() { public void onChanged(WheelView wheel, int oldValue, int newValue) { updateDays(year, month, day); } }; OnWheelScrollListener scrollListener = new OnWheelScrollListener() { public void onScrollingStarted(WheelView wheel) {} public void onScrollingFinished(WheelView wheel) {} }; // year int curYear = calendar.get(Calendar.YEAR); year.setViewAdapter(new DateNumericAdapter(this, curYear, curYear + 10,0)); year.setCurrentItem(curYear); year.addChangingListener(listener); year.addScrollingListener(scrollListener); // month int curMonth = calendar.get(Calendar.MONTH); String months[] = new String[] { "1月", "2月", "3月", "4月", "5月", "6月","7月", "8月", "9月", "10月", "11月", "12月" }; month.setViewAdapter(new DateArrayAdapter(this, months, curMonth)); month.setCurrentItem(curMonth); month.addChangingListener(listener); month.addScrollingListener(scrollListener); // day updateDays(year, month, day); day.setCurrentItem(calendar.get(Calendar.DAY_OF_MONTH) - 1); day.addScrollingListener(scrollListener); // hour int curHours = calendar.get(Calendar.HOUR_OF_DAY); hours.setViewAdapter(new DateNumericAdapter(this, 0, 23, curHours)); hours.setCurrentItem(curHours); hours.addScrollingListener(scrollListener); // minus int curMinutes = calendar.get(Calendar.MINUTE); mins.setViewAdapter(new DateNumericAdapter(this, 0, 59, curMinutes,"%02d")); mins.setCyclic(true); mins.setCurrentItem(curMinutes); mins.addScrollingListener(scrollListener); //second int curSeconds=calendar.get(Calendar.SECOND); seconds.setViewAdapter(new DateNumericAdapter(this, 0, 59, curSeconds,"%02d")); seconds.setCurrentItem(curSeconds); seconds.setCyclic(true); seconds.addScrollingListener(scrollListener); builder.create().show(); } } // 坐表 class OverItemT extends ItemizedOverlay<OverlayItem> { private List<OverlayItem> mGeoList = new ArrayList<OverlayItem>(); private Drawable marker; private RainStation mContext; private List<RainLineDao> listmp = null; // 存放获取的数据 public static List<RainLineDao> mRainLineDao; public OverItemT(Drawable marker, Context context, List<RainLineDao> mRainLineDao, int nowMapLeave) { super(boundCenterBottom(marker)); int t = 1; this.marker = marker; this.mContext = (RainStation) context; double mLat1 = 36.376601;// 39.9022; // point1纬度 double mLon1 = 116.90301;// 116.3822;// point1经度 List<String> data = new ArrayList<String>(); for (RainLineDao mposition : mRainLineDao) { data.add(mposition.getJingdu() + "," + mposition.getWeidu() + "," + mposition.getGsmwcdma() + "," + mposition.getGsmwcdma()); } if (nowMapLeave > 10 && nowMapLeave < 13) { t = 1; } else if (nowMapLeave == 10) { t = 20; } else if (nowMapLeave == 9) { t = 33; } else if (nowMapLeave == 8) { t = 40; } else if (nowMapLeave == 7) { t = 60; } else if (nowMapLeave == 6) { t = 80; } else if (nowMapLeave <= 5) { t = data.size(); } for (int i = 0; i < data.size(); i = i + t) { if (nowMapLeave < 5) { break; } /* * RainLineDao mposition = mRainLineDao.get(i); // for (RainLineDao * mposition : mRainLineDao) { mLat1 = * Double.parseDouble(mposition.getJingdu()); mLon1 = * Double.parseDouble(mposition.getWeidu()); * //mContext.mapController.setCenter(new GeoPoint((int) (mLon1 * * 1E6), // (int) (mLat1 * 1E6))); // 画出坐标 if (mLon1 != 0 && mLat1 * != 0) { mGeoList.add(new OverlayItem(new GeoPoint((int) (mLon1 * * 1E6), (int) (mLat1 * 1E6)), mposition.getGsmwcdma(), * mposition.getGsmwcdma())); } */ String str = data.get(i).replaceAll(" ", ""); String[] pstr = str.split(","); mLat1 = Double.parseDouble(pstr[1]); mLon1 = Double.parseDouble(pstr[0]); mGeoList.add(new OverlayItem(new GeoPoint((int) (mLat1 * 1E6), (int) (mLon1 * 1E6)), pstr[2], pstr[3])); mContext.progressDialog.dismiss(); } // 用给定的经纬度构造GeoPoint,单位是微度 (度 * 1E6) /* * for (Rposition mposition : listmp) { //画出坐标 if (mposition.getWeidu() * != 0 && mposition.getJingdu() != 0) { mGeoList.add(new OverlayItem( * new GeoPoint((int) (mposition.getWeidu() * 1E6), (int) * (mposition.getJingdu() * 1E6)), mposition .getAlarm_node(), * mposition.getGsmwcdma() + mposition.getInfo1())); } } */ populate(); // createItem(int)方法构造item。一旦有了数据,在调用其它方法前,首先调用这个方法 } @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { // Projection接口用于屏幕像素坐标和经纬度坐标之间的变换 Projection projection = mapView.getProjection(); for (int index = size() - 1; index >= 0; index--) { // 遍历mGeoList OverlayItem overLayItem = getItem(index); // 得到给定索引的item String title = overLayItem.getTitle(); // 把经纬度变换到相对于MapView左上角的屏幕像素坐标 Point point = projection.toPixels(overLayItem.getPoint(), null); // 在坐标点画红色的圆 Paint paintCircle = new Paint(); paintCircle.setColor(Color.RED); canvas.drawCircle(point.x, point.y, 5, paintCircle); // 画圆 if (overLayItem.getSnippet().equals("GSMVIP")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.g_vip); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("GSM")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.g_a); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("GSMB")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.g_b); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("GSMC")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.g_c); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("WCDMAVIP")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.w_vip); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("WCDMAA")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.w_a); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("WCDMAB")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.w_b); overLayItem.setMarker(boundCenterBottom(marker)); } else if (overLayItem.getSnippet().equals("WCDMAC")) { Drawable marker = mContext.getResources().getDrawable( R.drawable.w_c); overLayItem.setMarker(boundCenterBottom(marker)); } // 可在此处添加您的绘制代码 Paint paintText = new Paint(); paintText.setColor(R.color.dimgray); // paintText.setColor(Color.BLACK); // paintText.setSubpixelText(true); paintText.setTypeface(mContext.typeface); paintText.setTextSize(16); canvas.drawText(title, point.x - 30, point.y + 20, paintText); // 绘制文本 } super.draw(canvas, mapView, shadow); // 调整一个drawable边界,使得(0,0)是这个drawable底部最后一行中心的一个像素 boundCenterBottom(marker); } @Override protected OverlayItem createItem(int i) { return mGeoList.get(i); } @Override public int size() { return mGeoList.size(); } @Override // 处理当点击事件 protected boolean onTap(int i) { setFocus(mGeoList.get(i)); GeoPoint pt = mGeoList.get(i).getPoint(); MapView.LayoutParams geoLP = new MapView.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, pt, MapView.LayoutParams.BOTTOM_CENTER); mContext.mMapView.updateViewLayout(mContext.mPopView, geoLP); mContext.mPopView.setVisibility(View.VISIBLE); /*-------------------------------------------------------*/ //GWNODE_NAME 基站名称 String Gsmwcdma= RainStation.mRainLineDao.get(i).getGsmwcdma();//网络类别 String Site_abc= RainStation.mRainLineDao.get(i).getSite_abc();//基站级别 String Gwnode_name= RainStation.mRainLineDao.get(i).getGwnode_name();//基站名称 String Cells= RainStation.mRainLineDao.get(i).getCells();//小区 NJ187-党家支局O-41064,NJ187-党家支局O-41066 if(Cells.indexOf(",")>=0){ int end=Cells.indexOf(","); Cells=Cells.substring(0, end); // System.out.println("Cells:"+Cells); } //判断网络类型调用相应2G/3G接口 int j=-1,k=-1; if(Gsmwcdma.equals("GSM")){ for( j=0;j<RainStation.mRainLineDao2G.size();j++){ if(Cells.equals(RainStation.mRainLineDao2G.get(j).getCell_name())){ break; } } }else if(Gsmwcdma.equals("WCDMA")){ for( k=0;k<RainStation.mRainLineDao3G.size();k++){ if(Cells.equals(RainStation.mRainLineDao3G.get(k).getCell_name3G())){ break; } } } LinearLayout guideLinearLayout = (LinearLayout) mContext.mPopView .findViewById(R.id.con_s); guideLinearLayout.removeAllViews(); LinearLayout guide_typesitem = (LinearLayout) mContext.inflater .inflate(R.layout.thepopview, null); /*((Button) guide_typesitem.findViewById(R.id.g2_xiaoqu)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // Toast.makeText(mContext, "okok", // Toast.LENGTH_SHORT).show(); NewpopWindowsuntil aa = new NewpopWindowsuntil(mContext); aa.showPopwindows( mContext.findViewById(R.id.g2_xiaoqu), Gravity.CENTER, 0, 0); } });*/ ((TextView) guide_typesitem.findViewById(R.id.jizhan_names)).setText(RainStation.mRainLineDao.get(i).getGwnode_name());//基站名称 ((TextView) guide_typesitem.findViewById(R.id.jizhan_titles)).setText(RainStation.mRainLineDao.get(i).getCells());//小区 ((TextView) guide_typesitem.findViewById(R.id.jizhan_msc)).setText(RainStation.mRainLineDao.get(i).getRelated_msc());//所属MSC // Dn ((TextView) guide_typesitem.findViewById(R.id.jizhan_cdmas)).setText(RainStation.mRainLineDao.get(i).getGsmwcdma());//网络类别 // 类别 ((TextView) guide_typesitem.findViewById(R.id.jizhan_citys)).setText(RainStation.mRainLineDao.get(i).getArea_name());//地市 // 城市 ((TextView) guide_typesitem.findViewById(R.id.jizhan_bscs)).setText(RainStation.mRainLineDao.get(i).getRelated_bsc());//所属BSC/RNC // 标示 ((TextView) guide_typesitem.findViewById(R.id.jizhan_levels)).setText(RainStation.mRainLineDao.get(i).getSite_abc());//基站级别 // 生产厂商 ((TextView) guide_typesitem.findViewById(R.id.jizhan_jingdus)).setText(RainStation.mRainLineDao.get(i).getJingdu());//经度 // 经度 ((TextView) guide_typesitem.findViewById(R.id.jizhan_weidus)).setText(RainStation.mRainLineDao.get(i).getWeidu());//纬度 //添加全部信息到视图 guideLinearLayout.addView(guide_typesitem); //2G信息 if(j>=0){ LinearLayout guide_typesitem2G = (LinearLayout) mContext.inflater .inflate(R.layout.thepopview2g, null); // 所属MSS: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_mss)).setText(RainStation.mRainLineDao2G.get(j).getRelated_mss() );//纬度 // 业务信道总话务量ERL: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_erl)).setText(RainStation.mRainLineDao2G.get(j).getTch_traffic() );//纬度 //业务信道每信道话务量ERL: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_pererl)).setText(RainStation.mRainLineDao2G.get(j).getTch_pertraffic() );//纬度 // TCH掉话率: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_tch)).setText(RainStation.mRainLineDao2G.get(j).getTch_droprate() );//纬度 // 2G无线利用率: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_wireless_userate)).setText(RainStation.mRainLineDao2G.get(j).getWireless_userate() );//纬度 // 登记用户数: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_nbr_user)).setText(RainStation.mRainLineDao2G.get(j).getNbr_user() );//纬度 // 上行流量: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_psuioct)).setText(RainStation.mRainLineDao2G.get(j).getPsuioct() );//纬度 // 下行流量: ((TextView) guide_typesitem2G.findViewById(R.id.jizhan2g_psdioct)).setText(RainStation.mRainLineDao2G.get(j).getPsdioct() );//纬度 //添加2G信息到视图 guideLinearLayout.addView(guide_typesitem2G); } //3G信息 if(k>=0){ LinearLayout guide_typesitem3G = (LinearLayout) mContext.inflater .inflate(R.layout.thepopview3g, null); // 所属MSS: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_MSS)).setText(RainStation.mRainLineDao3G.get(k).getRelated_mss3G() );//纬度 // 分组域上行流量(KB): ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_psuioct)).setText(RainStation.mRainLineDao3G.get(k).getPsuioct3G() );//纬度 // 分组域下行流量(KB): ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_psdioct)).setText(RainStation.mRainLineDao3G.get(k).getPsdioct3G() );//纬度 // HSDPA RAB建立成功率: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_hsdpa_rab)).setText(RainStation.mRainLineDao3G.get(k).getHsdpa_rabrate() );//纬度 // HSUPA RAB建立成功率: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_hsupa_rab)).setText(RainStation.mRainLineDao3G.get(k).getHsupa_rabrate() );//纬度 // HSDPA平均在线用户数: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_hsdpa)).setText(RainStation.mRainLineDao3G.get(k).getHsdpa_meannbruser() );//纬度 // HSUPA平均在线用户数: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_hsupa)).setText(RainStation.mRainLineDao3G.get(k).getHsupa_meannbruser() );//纬度 // IUCS口话务量/电路域话务量(ERL): ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_cstraffic)).setText(RainStation.mRainLineDao3G.get(k).getCstraffic() );//纬度 // 登记用户数: ((TextView) guide_typesitem3G.findViewById(R.id.jizhan3g_nbr_user)).setText(RainStation.mRainLineDao3G.get(k).getNbr_user3G() );//纬度 guideLinearLayout.addView(guide_typesitem3G); } /*for (int index = size() - 1; index >= 0; index--) { OverlayItem overLayItem = getItem(index); if (overLayItem.getPoint().getLatitudeE6() == pt.getLatitudeE6() && overLayItem.getPoint().getLongitudeE6() == pt .getLongitudeE6() && !overLayItem.getTitle().equals( mGeoList.get(i).getTitle())) { LinearLayout guide_typesitems = (LinearLayout) mContext.inflater .inflate(R.layout.popviews, null); guideLinearLayout.addView(guide_typesitems); } }*/ return true; } @Override public boolean onTap(GeoPoint arg0, MapView arg1) { // 消去弹出的气泡 mContext.mPopView.setVisibility(View.GONE); return super.onTap(arg0, arg1); } }
发表评论
-
将Excel中的数据转换成sql Insert语句
2015-12-14 22:55 8581.或者用sql Server 2000 还有 导入的方 ... -
标准MD5
2015-05-23 14:56 515import java.security.Message ... -
加载时不直接弹出输入法
2015-05-23 10:38 606<?xml version="1.0&quo ... -
ActionBar-PullToRefresh集成好的Demo
2015-03-01 10:59 555ActionBar-PullToRefresh集成好的De ... -
手机设备的唯一标识符
2014-12-26 22:20 1984有很多场景和需求你需要用到手机设备的唯一标识符。例如,略。在 ... -
imageloader使用
2014-12-25 14:10 593http://blog.csdn.net/vipzjyno1/ ... -
仿京东时间选择器
2014-12-19 08:29 758运行效果图如下: 可选择当天10后19点前的时 ... -
仿京东时间选择器
2014-12-19 08:29 0运行效果图如下: 可选择当天10后19点前的时间 ... -
svn 报错
2014-09-17 13:03 614刚装SVN插件的时候没问题,可以连接服务器,后来因为公司一些 ... -
获取View距离父视图的高度
2014-07-26 14:05 1391/** * m_scrollview代表父视图 ... -
Android编程之仿微信显示更多文字的View (带源码)
2014-07-17 17:05 836引用:http://blog.csdn.net/xyz_f ... -
百度地图定位 BDLocationListener 不起作用
2014-06-14 09:46 1127最近利用百度地图的api和提供的demo做定位,发现用百度提 ... -
RadioButton 选中问题
2014-06-11 09:54 1171final RadioGroup radioGroup=( ... -
获取Android签名证书的sha1值MD5值
2014-05-19 11:24 30551.项目右键,Android Tools->Expo ... -
Android 播放器源码 vitamio 工具源码下载
2014-04-15 18:34 1196http://download.csdn.net/deta ... -
Android让Library中Manifest也包含进来
2014-02-27 15:22 3015Android可以通过use library来引用另一个P ... -
我的仿微信开发心得
2013-12-24 14:30 0刚开始我是信心满满的开发,很多东西就是为了实现而实现,结果,错 ... -
SlidingMenu带左右的
2013-12-17 17:34 372好用的,只有源码!!! -
Android图片处理内存溢出学习
2013-12-15 10:51 782最近遇到一个问题,在Android机器上,调用自带的相机拍摄 ... -
SlidingMenu-master中的example怎样导入eclipse运行
2013-12-13 00:51 1034相信能看这篇教程 ...
相关推荐
然而,由于百度地图使用的是自己的坐标系统(BD-09),与常见的WGS84坐标系不同,所以在使用Leaflet时直接加载百度地图会遇到兼容性问题。本教程将详细讲解如何通过Leaflet成功加载并显示百度地图。 首先,我们需要...
在本项目中,我们主要关注的是“BaiduMap.zip”这个压缩包,它包含了与百度地图相关的功能,如地图查询、附近的地点搜索、路径规划以及经纬度转换。下面将详细阐述这些功能及其在实际应用中的重要性。 首先,我们要...
要将百度地图与Cesium结合,我们主要需要处理两个关键步骤:获取百度地图的瓦片服务URL和在Cesium中添加这个自定义的地图源。 百度地图提供了瓦片服务API,我们可以根据API的规则构建瓦片请求URL。通常,这些URL会...
【百度地图H5地图选址】是一项利用JavaScript和jQuery技术在H5页面中实现类似饿了么地址选择的功能。这项技术可以让用户在网页上方便地进行地理位置的筛选和选择,为在线服务提供更精确的配送或服务范围设定。下面将...
"百度地图+echarts地图扩展"是一个将百度地图与ECharts图表库相结合的解决方案,它提供了丰富的地图绘制和交互功能,适用于各种业务场景,如城市规划、交通分析、商业选址等。下面我们将深入探讨这个主题。 首先,...
【标题】:“百度地图街景获取” 在当前的数字化时代,地图已经成为我们日常生活和工作中不可或缺的工具,尤其是在城市导航和位置服务中。其中,百度地图作为国内领先的在线地图服务平台,提供了丰富的地图数据和...
在OpenLayers中调用百度地图是一项常见的需求,特别是在构建Web GIS应用时,用户可能希望结合OpenLayers的强大功能和百度地图的丰富数据。OpenLayers是一个开源JavaScript库,用于创建交互式的地图应用,而百度地图...
在本教程中,我们将探讨如何在ArcGIS中加载百度地图算法,以便利用百度地图的数据和功能增强ArcGIS的性能。这个过程涉及到几个关键的技术点,包括地图投影、数据接口和API调用。 首先,我们需要了解地图投影的概念...
"百度地图瓦片下载无水印"是指一种工具或技术,能够从百度地图服务中获取地图图像,并且这些图像不包含百度地图通常显示的版权水印。这意味着用户可以更自由地使用这些地图数据,例如在制作自定义地图、GIS应用或者...
百度地图API是一组面向开发者的工具,允许开发者在自己的网站或应用中嵌入百度地图服务,如地图展示、定位、路线规划等。它提供了JavaScript API、RESTful服务等多种接口,方便开发者调用地图服务。 3. **接入步骤...
而调用百度地图API,可以让我们的应用与百度地图服务进行交互,实现如定位、地图显示、路线规划等功能。本篇文章将深入探讨如何在MFC项目中集成并使用百度地图API。 首先,了解百度地图API的基本概念是至关重要的。...
标题:“最新百度地图离线API” 百度地图离线API是开发者们在无网络环境下,仍能实现地图展示、定位、路径规划等功能的重要工具。这个“最新百度地图离线API”提供了一套完整的解决方案,使开发者能够在本地环境中...
将百度地图嵌入c# cs窗体中,cs后台控制百度地图: 1)用WebBrower控件加载本地的一个html文件,在html中实现加载百度地图 2)动态添加覆盖物 3)动态添加标签 4)动态添加点击小气球提示 5)经纬度提取详细地址 查...
将百度地图嵌入c# cs窗体中,cs后台控制百度地图: 1)用WebBrower控件加载本地的一个html文件,在html中实现加载百度地图 2)动态添加覆盖物 3)动态添加标签 4)动态添加点击小气球提示 5)经纬度提取详细地址 查...
【百度地图生成器】是一种工具,专为SEO(搜索引擎优化)设计,它的主要功能是帮助网站管理员生成适用于百度搜索引擎的地图。这种地图,通常被称为站点地图(Sitemap),是一种XML文件,列出了网站上的所有重要页面...
在这个过程中,我们首先需要理解百度地图API的使用,以及如何在Vue项目中集成BMap百度地图API来实现即时搜索功能。以下是详细知识点: 1. 百度地图API的申请和使用 要使用百度地图的即时搜索功能,开发者需要先在...
在本文中,我们将深入探讨如何将百度地图底图与Leaflet JavaScript库进行融合,以便在Web应用程序中创建交互式地图。Leaflet是一个轻量级、高性能的开源JavaScript库,广泛用于构建地图应用。而百度地图是中国领先的...
在Android开发中,百度地图API是一个非常常用的工具,它提供了丰富的地图展示、定位、路径规划等功能,极大地便利了开发者在构建地理位置相关应用时的工作。"老罗android 百度地图开发源码"是一个示例项目,它展示了...
本文将深入探讨“百度地图个性化弹出层和地图颜色”这一主题,旨在帮助开发者更好地利用百度地图API来创建独特且引人入胜的用户体验。 首先,让我们了解“百度地图个性化弹出层”。弹出层,也称为信息窗口或气泡,...