欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android如何自定義View實現(xiàn)公交成軌跡圖

這篇文章主要介紹Android如何自定義View實現(xiàn)公交成軌跡圖,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

成都創(chuàng)新互聯(lián)公司致力于網(wǎng)站設計制作、成都網(wǎng)站建設,成都網(wǎng)站設計,集團網(wǎng)站建設等服務標準化,推過標準化降低中小企業(yè)的建站的成本,并持續(xù)提升建站的定制化服務水平進行質(zhì)量交付,讓企業(yè)網(wǎng)站從市場競爭中脫穎而出。 選擇成都創(chuàng)新互聯(lián)公司,就選擇了安全、穩(wěn)定、美觀的網(wǎng)站建設服務!

具體內(nèi)容如下

總體分析下:水平方向recyclewview,item包含定位點,站臺位置和站臺名稱。

實現(xiàn):

1.繼承framelayout,實現(xiàn)構(gòu)造方法:

public class BusStopPlateView extends FrameLayout {... public BusStopPlateView(@NonNull Context context) { super(context); initView(context); } public BusStopPlateView(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); initView(context); } public BusStopPlateView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { super(context, attrs, defStyleAttr); initView(context); } private void initView(Context context) { ... //設置recycleview LayoutInflater.from(context).inflate(R.layout.xxx, this, true); mRecyclerView = (RecyclerView) findViewById(R.id.recycle); mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); mBusStopPlateAdapter = new BusStopPlateAdapter(mStationList); mRecyclerView.setAdapter(mBusStopPlateAdapter);  ...}...}

2.recycleview適配器:初始化的時候設置起點設置終點設置車道設置當前車位置的下標

/** * 設置車道 */ private void setDriveway(BaseViewHolder helper, BusStopPlateStationInfo item) { if (helper.getAdapterPosition() <= adminCurrentIndex) {  helper.getView(R.id.v_daolu).setSelected(true);  helper.getView(R.id.iv_jiantou).setSelected(true); } else {  helper.getView(R.id.v_daolu).setSelected(false);  helper.getView(R.id.iv_jiantou).setSelected(false); } } /** * 設置起點 */ private void setStartStation(BaseViewHolder helper, BusStopPlateStationInfo item) { helper.setVisible(R.id.v_daolu, false)  .setBackgroundRes(R.id.iv_jiantou, R.drawable.bg_busstop_vdaolu_start); } /** * 設置終點 */ private void setEndStation(BaseViewHolder helper, BusStopPlateStationInfo item) { helper.setBackgroundRes(R.id.iv_jiantou, R.drawable.bg_busstop_vdaolu_end)  .setBackgroundRes(R.id.v_daolu, R.drawable.bg_busstop_vdaolu_end)  .setVisible(R.id.v_zhanwei, true)  .setVisible(R.id.v_daoli_zhanwei, false); } /** * 設置當前所在站點 */ private void setCurrentStation(BaseViewHolder helper, BusStopPlateStationInfo item) { mCurrentView = helper.getConvertView(); helper.setVisible(R.id.bus_stop_reach, true)  .setVisible(R.id.iv_bus_stop_current, false)  .setVisible(R.id.tv_bus_stop_current_num, false)  .setVisible(R.id.iv_current_point, true)  .setVisible(R.id.iv_admin_index, true)  // 顯示占位符,用于顯示一半的灰色  .setBackgroundRes(R.id.v_daoli_zhanwei, R.drawable.bg_busstop_vdaolu)  .setVisible(R.id.v_daoli_zhanwei, true);//  .setTextColor(R.id.tv_bus_station_name, Color.parseColor("#3D93FD")); Glide.with(mContext)  .load(R.drawable.bus_icon_fangxiang_current)  .crossFade()  .into((ImageView) helper.getView(R.id.iv_current_point)); List<AliveBusInfo> aliveBusInfos = item.getAliveBusInfos(); if (aliveBusInfos != null && aliveBusInfos.size() != 0) {  AliveBusInfo aliveBusInfo = aliveBusInfos.get(0);  if ("1".equals(aliveBusInfo.getStStatus()) && aliveBusInfo.getStName().equals(item.getStName())) {  helper.setVisible(R.id.iv_admin_index, false)   .setVisible(R.id.iv_bus_stop_current, true)   .setImageResource(R.id.iv_bus_stop_current, R.drawable.bus_stop_current);  } } else {  Glide.with(mContext)   .load(R.drawable.icon_admin_current_station)   .crossFade()   .into((ImageView) helper.getView(R.id.iv_admin_index)); } } /** * 設置公交所在站點 */ private void setBusStation(BaseViewHolder helper, BusStopPlateStationInfo item) { List<AliveBusInfo> aliveBusInfos = item.getAliveBusInfos(); if (aliveBusInfos != null && aliveBusInfos.size() != 0) {  AliveBusInfo aliveBusInfo = aliveBusInfos.get(0);  if ("0".equals(aliveBusInfo.getStStatus())) {  // 在車道上  helper.setVisible(R.id.bus_stop_not_to, true)   .setVisible(R.id.bus_stop_reach, false)   .setText(R.id.tv_stop_not_to_num, String.valueOf(aliveBusInfos.size()))   // 顯示在過道中的車   .setVisible(R.id.iv_stop_not_to, aliveBusInfos.size() != 0)   // 是否顯示數(shù)字   .setVisible(R.id.tv_stop_not_to_num, aliveBusInfos.size() > 1);  // 如果已經(jīng)過站 顯示灰色圖標  if (aliveBusInfo.getStCount() < 0) {   GlideUtils.loadImageView(mContext, R.drawable.bus_stop_over_station_min, helper.getView(R.id.iv_stop_not_to));  } else {   GlideUtils.loadImageView(mContext, R.drawable.bus_stop_not_to, helper.getView(R.id.iv_stop_not_to));  }  } else if ("1".equals(aliveBusInfo.getStStatus())) {  // 到站  helper.setVisible(R.id.bus_stop_not_to, false)   .setVisible(R.id.bus_stop_reach, true)   .setVisible(R.id.iv_admin_index, true)   .setVisible(R.id.iv_bus_stop_current, false)   .setVisible(R.id.tv_bus_stop_current_num, aliveBusInfo.getStCount() > 1)   .setText(R.id.tv_bus_stop_current_num, String.valueOf(aliveBusInfos.size()));  // 如果已經(jīng)過站 顯示灰色圖標  if (aliveBusInfo.getStCount() < 0) {   GlideUtils.loadImageView(mContext, R.drawable.bus_stop_over_station, helper.getView(R.id.iv_admin_index));  } else {   GlideUtils.loadImageView(mContext, R.drawable.bus_stop_not_to, helper.getView(R.id.iv_admin_index));  }  } } else {  // 隱藏公交車  helper.setVisible(R.id.bus_stop_not_to, false)   .setVisible(R.id.bus_stop_reach, false); } }

3.外部activity的點擊事件:點擊文字的時候?qū)斍拔恢脤ο笏⑿碌竭x擇的位置,刷新recycleview

mBusStopPlateView.setOnBusStopPlateViewItemClick(new BusStopPlateView.onBusStopPlateViewEvent() {  @Override  public void onItemClick(BusStopPlateStationInfo station) {  stationId = station.getStId();  stationName = station.getStName();  exportStationInfo(mBusStopPlateView.getStationList());  aliveBusRefresh();  //當上車提醒保存的信息與當前候車站點信息不一致時恢復為上車提醒,  // 并在點擊上車提醒是判斷是否更新上車提醒的站點  BusRemind remind = SpKeyConfig.getOnRemind();  if (remind != null) {   if (remind.getStationId().equals(stationId) &&    remind.getLineId().equals(mLineId)) {   tvOnRemind.setText("取消提醒");   ivOnRemind.setImageResource(R.drawable.bus_icon_onremind_on);   } else {   tvOnRemind.setText("上車提醒");   ivOnRemind.setImageResource(R.drawable.bus_icon_onremind_off);   }  }  }  @Override  public void onCurrentViewPosition(int x, int y, boolean isVisibility) {  mIvPoint.setTranslationX(x - mIvPoint.getWidth() / 2 + 6);  mIvPoint.setVisibility(isVisibility ? View.VISIBLE : View.INVISIBLE);  } }

以上是“Android如何自定義View實現(xiàn)公交成軌跡圖”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

分享標題:Android如何自定義View實現(xiàn)公交成軌跡圖
網(wǎng)頁網(wǎng)址:http://aaarwkj.com/article20/ijpoco.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設計公司虛擬主機、動態(tài)網(wǎng)站定制開發(fā)、App設計Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設
日韩新片一区二区三区| 久久亚洲女同第一区综合| 久久热在线观看免费高清| 97资源视频在线播放| 日韩中字伦理熟妇人妻| 亚洲国产日韩精品自拍av| 国内成人午夜激情视频| 亚洲av毛片在线免费| 精品国产不卡在线观看| 蜜桃网站视频免费观看| 日韩有码在线中文字幕| 国产精品三级玖玖玖电影| 小仙女精品经典三级永久| 国产激情盗摄一区二区三区| 亚洲精品一区二区免费看| 亚洲精品一区二区日本| 日韩亚洲av一区二区| 日韩精品高清视频在线观看| 操你啦夜夜操狠狠躁天天爽| 日韩av在线高清播放| 97在线视频这里只有精品| 爱我久久视频网免费视频| 丰满高潮少妇在线观看| 久久综合午夜福利视频| 欧美日韩亚洲中文字幕| 精品人妻区二区三区蜜桃| 99精品一二三日韩| 欧美日本在线区一区二| 亚洲全乱码精品一区二区| 日韩激情中文字幕一区二区三区| 国产精品久久午夜伦鲁鲁| 人妻巨乳一区二区三区| 欧美一区二区三区日| 男女午夜激情啪啪视频| 日韩精品国产自拍在线| 精品人妻一区二区三区乱码| 婷婷五五月深爱开心激情| va精品人妻一区二区三区| 亚洲国产丁香综合激情啪| 国产av高清视频在线| 精品久久久久久久中文字幕|