新聞中心

        EEPW首頁 > 汽車電子 > 設(shè)計(jì)應(yīng)用 > 基于Android的公交車載中控控制系統(tǒng)的實(shí)現(xiàn)

        基于Android的公交車載中控控制系統(tǒng)的實(shí)現(xiàn)

        作者:張維文 馬杰 孫樹娟 王彬宇 李利娟 時(shí)間:2015-04-26 來源:電子產(chǎn)品世界 收藏

          實(shí)現(xiàn)主界面主要代碼及分析:

        本文引用地址:http://www.104case.com/article/273184.htm

          在res/layout目錄下創(chuàng)建一個(gè)布局文件.xml,使用LinearLayout線性布局,內(nèi)層使用TableView。下面是以地圖展示和手動(dòng)報(bào)站兩個(gè)功能按鈕為例的代碼:

               android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="#005aaa"
          android:gravity="center"
          android:padding="12dip"
          android:text="Location"
          android:textColor="#ffffff"
          android:textSize="18sp" />
               android:id="@+id/Main_Map"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:background="@drawable/btn_bg"
          android:text="地圖展示"
          android:textColor="@android:color/white"
          android:textSize="16sp" />
               android:id="@+id/Main_ReporStation"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:background="@drawable/btn_bg"
          android:text="手動(dòng)報(bào)站"
          android:textColor="@android:color/white"
          android:textSize="16sp" />

          在名為MainActivity的Activity中,建立一個(gè)onCreate()方法,設(shè)置Activity界面標(biāo)題和布局,實(shí)例化各個(gè)Button組件,并對(duì)各個(gè)Button設(shè)置OnClickListener進(jìn)行監(jiān)聽,當(dāng)點(diǎn)擊不同的Button按鈕時(shí),就會(huì)跳轉(zhuǎn)到不同的功能界面。下面是地圖展示功能實(shí)現(xiàn)工程的代碼:

          mapBtn.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
          String latStr = latitude.getText().toString();
          String lonStr = longitude.getText().toString();
          if (latStr == null || latStr.equals("") || lonStr == null || lonStr.equals("")) {
          Toast.makeText(MainActivity.this, "請(qǐng)先等定位完成后再展示地圖", Toast.LENGTH_LONG).show();
          return;
          }
          Intent intent = new Intent(MainActivity.this,GeoActivity.class);
          intent.putExtra("latitude", latStr);
          intent.putExtra("longitude", lonStr);
          startActivity(intent);
          }
          });

          3.3 網(wǎng)絡(luò)設(shè)置實(shí)現(xiàn)

          客戶端的數(shù)據(jù)存放在客戶端的SQLite數(shù)據(jù)庫中,服務(wù)器端要想獲得數(shù)據(jù)必須通過網(wǎng)絡(luò)的傳輸。網(wǎng)絡(luò)設(shè)置界面如圖5所示。

        linux操作系統(tǒng)文章專題:linux操作系統(tǒng)詳解(linux不再難懂)

        linux相關(guān)文章:linux教程




        關(guān)鍵詞: Android APP SDK GPS Wi-Fi

        評(píng)論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 大港区| 台北市| 东乌| 黔西| 九寨沟县| 清丰县| 庆阳市| 正定县| 饶平县| 水城县| 邵阳市| 绍兴县| 淮阳县| 建宁县| 平阳县| 高雄县| 尼玛县| 高要市| 抚松县| 弥渡县| 东阳市| 甘德县| 昌图县| 衡南县| 馆陶县| 亳州市| 绥德县| 丰县| 东至县| 连城县| 册亨县| 弥渡县| 甘孜| 新竹市| 台南市| 绿春县| 城固县| 揭阳市| 北碚区| 仪征市| 固阳县|