I am facing this problem where i get a runtime exception android.view.InflateException and traces the error in the xml file where i have declared the MapView using the Map API key and says that the MapView cant be inflated... i have two activities where one activity invokes this class containing the mapView, earlier when i had just one activity ,it was working fine. Thanx in advance
XML File:
<view class="com.google.android.maps.MapView"
android:id="@+id/myMapView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0px"
android:enabled="true"
android:clickable="true"
android:apiKey="removedtheapikeybecauseitssuppoedtobesecrut"
android:layout_y="105px" />
Activity 1
public 开发者_运维知识库void onCreate(Bundle savedInstanceState)
{
Log.i("MyActivity", "MyClass.getView() — get item number ");
try
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button submit = (Button)findViewById(R.id.BtnSubmit);
EditText range= (EditText)findViewById(R.id.EditRange);
EditText EditRange = null;
String value= EditRange.getText().toString();
final Bundle bundle= new Bundle();
bundle.putString("param1",value);
submit.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
Intent myIntent = new Intent(view.getContext(), RoutePath.class);
myIntent.putExtras(bundle);
startActivity(myIntent);
}
});
}
catch(Exception e)
{
Log.d("My Activity",e.getMessage());
e.printStackTrace();
}
Activity 2
public class RoutePath extends MapActivity
{
public void onCreate(Bundle savedInstanceState)
{
//View view;
//Context context;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.myMapView1);
mapView.setBuiltInZoomControls(true);
}
}
I think the problem is you are using
setContentView(R.layout.main);
for RoutePath. Pretty sure you should be using a different xml here.
精彩评论