基于A(yíng)ndroid的公交車(chē)載中控控制系統的實(shí)現
實(shí)現主界面主要代碼及分析:
本文引用地址:http://dyxdggzs.com/article/273184.htm 在res/layout目錄下創(chuàng )建一個(gè)布局文件.xml,使用LinearLayout線(xiàn)性布局,內層使用TableView。下面是以地圖展示和手動(dòng)報站兩個(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)報站"
android:textColor="@android:color/white"
android:textSize="16sp" />
在名為MainActivity的Activity中,建立一個(gè)onCreate()方法,設置Activity界面標題和布局,實(shí)例化各個(gè)Button組件,并對各個(gè)Button設置OnClickListener進(jìn)行監聽(tīng),當點(diǎn)擊不同的Button按鈕時(shí),就會(huì )跳轉到不同的功能界面。下面是地圖展示功能實(shí)現工程的代碼:
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í)現
客戶(hù)端的數據存放在Android客戶(hù)端的SQLite數據庫中,服務(wù)器端要想獲得數據必須通過(guò)網(wǎng)絡(luò )的傳輸。網(wǎng)絡(luò )設置界面如圖5所示。
linux操作系統文章專(zhuān)題:linux操作系統詳解(linux不再難懂)
linux相關(guān)文章:linux教程
評論