我需要将LatLng类的实例传递给另一个intent.我该怎么办?这是代码.
LatLng fromPosition = new LatLng(23.4555453556, 11.145315551);
LatLng toPosition = new LatLng(12.1115145311, 99.333455333);
Intent i= new Intent(Maps.this, Routes.class);
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
请帮帮我.
路线类:
public class Routes extends FragmentActivity {
GoogleMap mMap;
GMapV2Direction md;
private String provider;
double lati;
double longi;
String name;
Location location;
Document doc;
PolylineOptions rectLine;
Bundle bundle = getIntent().getParcelableExtra("bundle");
LatLng fromPosition = bundle.getParcelable("from_position");
LatLng toPosition = bundle.getParcelable("to_position");
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps2);
md = new GMapV2Direction();
mMap = ((SupportMapFragment)getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
LatLng coordinates = fromPosition;
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(coordinates, 16));
mMap.addMarker(new …
Run Code Online (Sandbox Code Playgroud) 我试图从edittext框中获取值,并且在单击按钮时,我想比较edittext框内的文本是否与某个值匹配.如果是,则应调用新意图.如果不是,则应显示错误.单击按钮后,这是我的代码...
if(v.getId() == R.id.button1){
id = et1.getText().toString();
Toast toast = Toast.makeText(this, "Value of id is: " + id, Toast.LENGTH_SHORT);
toast.show();
if(id == "abc"){
Intent i= new Intent(Slogin.this, Sales.class);
startActivity(i);
}else{
Toast toast = Toast.makeText(this, "Wrong id pass", Toast.LENGTH_SHORT);
toast.show();
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,即使我输入"abc"(没有双逗号),它仍然显示错误"错误的id传递".虽然Toast清楚地表明我已输入abd并且字符串id现在保持值"abc".需要帮助......