我已经在这一个多星期了。我试过在我的应用中设置Google地图活动,但没有运气。我也看到你可以从你的应用程序调用Google地图应用程序。通过使用Onclicklistener。如何使用按钮从我的应用程序打开Google地图应用程序?这是我使用的代码...谷歌地图使用按钮/ Onclicklistener打开谷歌地图应用
import com.google.android.maps.GeoPoint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Store10 extends Activity {
Context context;
GeoPoint geo;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.store10);
Button num10 = (Button) findViewById(R.id.pNumber10);
Button nav10 = (Button) findViewById(R.id.Map10);
num10.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(view.getContext() ,Num10.class);
startActivityForResult(myIntent, 0);
}
});
nav10.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
String uri = String.format("geo:%f,%f",40,325874,76,002211);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
}
});
}
}
这里的Onclicklistener我试图建立
nav10.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
// TODO Auto-generated method stub
String uri = String.format("geo:%f,%f",40,325874,76,002211);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
}
});
什么是对的OnClick错误??? –