新聞中心

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

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

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

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

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

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

               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="手動報站"
          android:textColor="@android:color/white"
          android:textSize="16sp" />

          在名為MainActivity的Activity中,建立一個onCreate()方法,設(shè)置Activity界面標題和布局,實例化各個Button組件,并對各個Button設(shè)置OnClickListener進行監(jiān)聽,當(dāng)點擊不同的Button按鈕時,就會跳轉(zhuǎn)到不同的功能界面。下面是地圖展示功能實現(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, "請先等定位完成后再展示地圖", 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è)置實現(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

        評論


        相關(guān)推薦

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

        關(guān)閉
        主站蜘蛛池模板: 连平县| 阿拉善盟| 安溪县| 白银市| 扎鲁特旗| 咸宁市| 吉安市| 贡嘎县| 公主岭市| 芜湖县| 界首市| 宁德市| 曲松县| 普兰县| 泽库县| 丰宁| 杭锦旗| 大石桥市| 怀宁县| 柳林县| 望谟县| 东山县| 孝义市| 岳普湖县| 甘南县| 八宿县| 成武县| 永靖县| 西峡县| 皋兰县| 泰兴市| 恩平市| 陕西省| 司法| 宜丰县| 天峨县| 大方县| 开江县| 韩城市| 镇雄县| 彭州市|