草庐IT

format-specifiers

全部标签

java - 为什么 String.format() 在 Android TextView 上不起作用?

我正在尝试格式化AndroidTextView上的文本。这是我在Java控制台中尝试的代码:System.out.println(String.format("%-7s56","S"));System.out.println(String.format("%-7s56","A(102)"));输出是预期的,我的文本是左对齐的:S56A(102)56不,我在AndroidTextView上尝试相同的代码:mTextView.setText(String.format("%-7s56\n","S"));mTextView.append(String.format("%-7s56","A(1

java - 从 GIT 添加模块到 Android Studio 抛出 "buildToolsVersion is not specified"错误

我想包括thisColorPicker进入我的AndroidStudio项目。所以我将它checkout到本地文件夹中,使用“AndroidStudio中的新建->导入模块对话框”将其添加到我的项目中。然后我将这两行添加到我的app.gradle文件中applyplugin:'com.android.application'...compileproject(':colorpicker')这里是完整的gradle文件applyplugin:'com.android.application'android{compileSdkVersion24buildToolsVersion'24.0

android - 使 : *** No targets specified and no makefile found. 停止

这个问题看起来与make***notargetsspecifiedandnomakefilefound.stop重复但我的问题略有不同,我也尝试了该解决方案,但对我不起作用。我正在研究OpenCV库,我从示例项目开始,但这给我带来了以下错误。请帮我解决这个错误。17:31:25****AutoBuildofconfigurationDefaultforprojectMyFirstOpenCVJNI****makemake:***Notargetsspecifiedandnomakefilefound.Stop.17:31:25BuildFinished(took122ms)以下是我的A

android - APK 扩展文件 : Specifying library path in Android Studio (Windows)

我在AndroidStudio(Windows10)上。我一直在尝试按照https://developer.android.com/google/play/expansion-files.html中的步骤进行操作但我停留在“准备使用下载程序库”部分。我已经下载并安装了GooglePlayLicenseLibrary和GooglePlayDownloaderLibrary。我已经创建了相应的模块。但是,当我转到“模块设置”并指定库存储库的路径时,出现错误,当我再次打开“模块设置”时,“库存储库”字段仍为空白。我得到的错误是:10:23:57PMIncorrectOperationExce

安卓-GridView : Specify Column Span

如何在android的gridview中指定列跨度?我有一个gridview,每行显示3个图像。有时,有些图像必须跨越2行。在Android中可以这样做吗?还是我应该使用不同的View? 最佳答案 TableLayout和GridLayout支持列跨越,但GridView不支持。 关于安卓-GridView:SpecifyColumnSpan,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/quest

java - 如何通过英文的 String.format 返回格式化的数字?

当我使用String.format方法时,如果我的电话语言是波斯语,则此方法返回波斯语格式的数字。但我想使用英文格式的数字。我使用这段代码:String.format("%.02f",myNumber)图中我的问题: 最佳答案 我认为您需要使用String.format(Locale,String,...)带有英语Locale实例的方法,可能带有Locale.ENGLISH。这将告诉String.format使用英文数字格式而不是波斯语。 关于java-如何通过英文的String.for

java - 比较 Formate 为 yyyy-MM-dd HH :mm:ss in Android 的两个日期和时间

我必须比较两个格式为yyyy-MM-ddHH:mm:ss的日期。我知道只比较日期之前或之后的日期功能的方法。SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss");StringcurrentDateandTime=sdf.format(newDate());StringexpiryTime="2014-09-1000:00:00";但是比较日期和时间与当前日期和时间的最佳方式是什么。就像我们有两个日期2014-09-1000:00:00,当前日期和时间是2014-08-3110:37:15。现在我们必须比较它。我们如何

android - Gradle : No resource type specified (at 'text' with value '@{user.name}' ). 数据绑定(bind)不工作

我试图将适当的数据绑定(bind)功能添加到我的项目中,但由于某种原因它仍然失败。build.gradle文件如下所示:applyplugin:'com.android.application'buildscript{repositories{mavenCentral()}dependencies{classpath'me.tatarka:gradle-retrolambda:3.2.5'}}repositories{mavenCentral()}applyplugin:'com.android.application'applyplugin:'me.tatarka.retrolamb

安卓数据绑定(bind) : conditional formatting to set layout_weight

如何使用android数据绑定(bind)在xml中设置layout_weight?在dimens文件夹中,我们提供dp/sp中的值。 最佳答案 这是一个适合我的绑定(bind)适配器,你的View确实需要在LinearLayout中,我认为如果你想设置权重的话:@BindingAdapter("android:layout_weight")funsetLayoutWeight(view:View,weight:Float){vallayoutParams=view.layoutParamsas?LinearLayout.Layou

android - 如何在安卓设备上指定 OUTPUT_FORMAT_MPEG2TS

我很困惑为什么我不能使用OutputFormat.OUTPUT_FORMAT_MPEG2TS作为参数调用MediaRecorder.setOutputFormatAndroid版本2.3.6上的方法调用?在android源码中有这样一段代码:/***Definestheoutputformat.Theseconstantsareusedwith*{@linkMediaRecorder#setOutputFormat(int)}.*/publicfinalclassOutputFormat{/*Donotchangethesevalueswithoutupdatingtheircount