有没有办法让它ViewPager不是水平滚动,而是垂直滚动?!
我已将自定义字体文件添加到我的assets/fonts文件夹中.如何从我的XML中使用它?
我可以从代码中使用它如下:
TextView text = (TextView) findViewById(R.id.textview03);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Molot.otf");
text.setTypeface(tf);
Run Code Online (Sandbox Code Playgroud)
我不能使用android:typeface="/fonts/Molot.otf"属性从XML做到吗?
当我点击谷歌地图上的标记时,出现"导航"和"GPS指针"按钮.如何在android开发中以编程方式隐藏这两个按钮?

我是Typescript的新手,不知道怎么说这个问题.
我需要访问构造函数中传递的对象的两个"可能"属性.我知道我缺少一些检查以确定它们是否已定义,但是Typescript正在向我抛出"'对象'上不存在属性"消息.消息显示在选择器上,模板返回.
class View {
public options:Object = {};
constructor(options:Object) {
this.options = options;
}
selector ():string {
return this.options.selector;
}
template ():string {
return this.options.template;
}
render ():void {
}
}
Run Code Online (Sandbox Code Playgroud)
我确信它相当简单,但是Typescript对我来说是新的.
我的应用程序的一部分需要位置服务,因此如果当前关闭位置,应用程序将提示用户启用它.下面是我正在做它:(也见于这个堆栈溢出的答案)
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
builder.setAlwaysShow(true);
PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>()
{
@Override
public void onResult(LocationSettingsResult result)
{
final Status status = result.getStatus();
final LocationSettingsStates = result.getLocationSettingsStates();
switch (status.getStatusCode())
{
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can initialize location
// requests here.
...
Log.d("onResult", "SUCCESS");
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. But could be fixed by showing the user
// a dialog.
Log.d("onResult", "RESOLUTION_REQUIRED");
try …Run Code Online (Sandbox Code Playgroud) 在清单文件中,我添加了粗略和精细的权限,当我在使用Android 6的设备上运行时,没有任何反应!我尝试了一切,但无法获得位置更新......
我究竟做错了什么?
public class MainActivity extends AppCompatActivity implements LocationListener {
LocationManager locationManager;
String provider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
provider = locationManager.getBestProvider(new Criteria(), false);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. …Run Code Online (Sandbox Code Playgroud) 我想谷歌地图显示用户的位置.我尝试了这段代码,但它在Android 6上无效.
private GoogleMap map;
LocationManager lm;
LocationListener ll;
Location l;
LatLng pos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start_layout);
lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
ll = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
l = (Location) location;
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onProviderDisabled(String provider) {}
};
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.nMap);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
map = …Run Code Online (Sandbox Code Playgroud) 我想替换已弃用的getMap方法getMapAsync,但我没有使用,MapFragment但是GoogleMap像这样:
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
try {
if(googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMyLocationEnabled(true);
googleMap.setTrafficEnabled(true);
googleMap.setIndoorEnabled(true);
googleMap.setBuildingsEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
Run Code Online (Sandbox Code Playgroud)
如果我更换googleMap与MapFragment这样我不能再对setMapType等.那么我怎么能改变getMapAsync我的情况呢?
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Run Code Online (Sandbox Code Playgroud) 谷歌搜索,阅读数百万关于如何生成谷歌API密钥的建议,如何使用它但没有任何作用!
然后:
提前感谢任何建议.
兹德涅克
我想定期(比如每2分钟)当前位置更新为这个我下面的官方文档,我写了这个代码,但它不会给当前的位置即使在我传递requestLocationUpdates LocationRequest对象指定每两分钟更新( ),这里是代码:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
private FusedLocationProviderClient FusedLocationClient;
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
if (mGoogleApiClient == null) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
SupportMapFragment map =
getSupportFragmentManager().findFragmentById(R.id.map));
map.getMapAsync(this);
FusedLocationClient LocationServices.getFusedLocationProviderClient(this);
}
@Override
public void onConnected(Bundle bundle) {
FusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {
Log.i("MainActivity ", "" + location.getLongitude())
}
}
});
FusedLocationClient = …Run Code Online (Sandbox Code Playgroud) java android google-maps-android-api-2 android-fusedlocation