我有这个包含谷歌地图 v2 的 xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snapshot" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
和我的活动
public class display extends Activity {
GoogleMap map;
File dbFile;
String first_lat,first_long;
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gps_map);
PolylineOptions line = new PolylineOptions();
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
/*
* Adatbázis
*/
try {
dbFile = getDatabasePath("/mnt/sdcard/Download/TeleSensors.db");
} catch (Exception e) {
}
SQLiteDatabase myDataBase = SQLiteDatabase.openDatabase(
dbFile.getAbsolutePath(), null, SQLiteDatabase.OPEN_READONLY);
Cursor cur_lat = myDataBase.rawQuery(
"select * from GPS_Values where id = 1;", null);
Integer count1 = 0;
while (cur_lat.moveToNext()) {
first_lat = cur_lat.getString(1);
first_long = cur_lat.getString(2);
count1++;
Log.e("Elsok",
first_lat.toString() + " --- " + first_long.toString());
}
Cursor curTAB = myDataBase.rawQuery("SELECT * FROM GPS_Values;", null);
Integer count = 0;
while (curTAB.moveToNext()) {
String s_latitude = curTAB.getString(1);
String s_longitude = curTAB.getString(2);
count++;
double latitude = Double.parseDouble(s_latitude);
double longitude = Double.parseDouble(s_longitude);
line.add(new LatLng(latitude, longitude));
Log.i("Coordinates",
s_latitude.toString() + " --- " + s_longitude.toString());
}
curTAB.close();
myDataBase.close();
// adatbázis vége
double latitude = Double.parseDouble(first_lat);
double longitude = Double.parseDouble(first_long);
map.addPolyline(line);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
map.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
gomb_figyelo();
}
private void gomb_figyelo() {
// TODO Auto-generated method stub
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SnapshotReadyCallback callback = new SnapshotReadyCallback() {
Bitmap bitmap;
public void onSnapshotReady(Bitmap snapshot) {
// TODO Auto-generated method stub
bitmap = snapshot;
try {
FileOutputStream out = new FileOutputStream(
"/mnt/sdcard/Download/TeleSensors.png");
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
Toast.makeText(
getApplicationContext(),
"A képernyőkép kimentve: /mnt/sdcard/Download/TeleSensors.png",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}
}
};
map.snapshot(callback);
}
});
}
}
并收到此错误消息:
08-14 17:22:43.509: E/AndroidRuntime(13760): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eyecom.tools.telesensors/com.eyecom.tools.telesensors.display}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
你能帮我吗,因为在 #15 行中只有片段