我正在为我的应用添加一个MapFragment,并提供以下代码,改编自地图教程:
private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {
// In debug mode, log the status
Log.d("Location Updates", "Google Play services is available.");
// Continue
return true;
// Google Play services was not available for some reason
} else {
GooglePlayServicesUtil.getErrorDialog(resultCode, this, 7).show();
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用过时的谷歌播放服务在出厂重置Galaxy选项卡10.1上进行测试.因此,当我尝试打开MapFragment时,我打电话servicesConnected()来检查,并且正如预期的那样,我得到一个对话框,告诉我我需要Google Play服务.在对话框的底部有一个"获取Google Play服务"按钮,但是当我点击它时,它什么也没做.我的LogCat产生以下输出:
07-23 15:30:43.580: W/GooglePlayServicesUtil(2515): Google Play services is missing. …Run Code Online (Sandbox Code Playgroud) 我收到以下错误,不知道为什么.一段时间之前,我的应用程序正在手机上正确安装,但现在这个错误消息被触发了.
[2012-05-16 11:18:56 - ClubDangoV2Released] Failed to install ClubDangoV2Released.apk on device 'S55706733529a': Too many open files
[2012-05-16 11:18:56 - ClubDangoV2Released] com.android.ddmlib.SyncException: Too many open files
[2012-05-16 11:18:56 - ClubDangoV2Released] Launch canceled!
Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序.它中有很多按钮,但这些按钮是在运行时创建的.如果我设置宽度button.setwidth(300),它将宽度设置为300px.我希望宽度设置为dp.有什么办法吗?
我四处寻找解决方案,但似乎这不是一个常见的问题.
当我的应用程序连接到服务器然后清除该对话框并在请求完成时显示不同的对话框时,我希望有一个不确定的对话框微调器.我正在使用Fragment兼容包.问题是在显示第二个对话框之前没有删除微调器.
这是我的代码,显示对话框,并应删除任何当前的对话框:
void displayDialog(int type, String message) {
Log.i(logTag, "displayDialog: " + type);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
if (prev != null) {
Log.i(logTag, "removing previous dialog");
ft.remove(prev); //TODO maybe use ((DialogFragment)dialog).dismiss(); ?
}
ft.addToBackStack(null);
// Create and show the dialog.
DialogFragment newFragment = DialogHelperFragment.newInstance(type, message);
newFragment.show(ft, "dialog");
}
Run Code Online (Sandbox Code Playgroud)
这是我用来解决这个bug的调用代码:
displayDialog(DialogHelperFragment.DIALOG_PROGRESS, null);
displayDialog(DialogHelperFragment.DIALOG_PURCHASE_SUCCESS, null);
Run Code Online (Sandbox Code Playgroud)
这是我对应的LogCat输出:
06-25 13:53:35.497: I/tag(11008): displayDialog: 8
06-25 13:53:35.497: I/tag(11008): displayDialog: 7
06-25 13:53:35.897: I/tag Dialog Helper(11008): Creating Dialog: 8
06-25 …Run Code Online (Sandbox Code Playgroud) 我正在尝试从UIAlertController获取textField值,但每当我尝试输入值并尝试将其打印出来时,输出都不会显示任何内容.
码:
var alert = UIAlertController(title: "Enter the password", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
alert.addTextFieldWithConfigurationHandler({(textField: UITextField!) in
textField.placeholder = "Enter text:"
textField.secureTextEntry = true
println(textField.text)
})
self.presentViewController(alert, animated: true, completion: nil
Run Code Online (Sandbox Code Playgroud) 如何在我的Web视图中打开PDF文件而不下载并将其保存到SD卡?我已经做了一些研发,但直到现在我还没有得到任何合适的答案.谁能告诉我如何使用googledoc在Web视图中打开PDF文件?