默认情况下,Android Studio会自动为所有新类添加标题注释,例如
/**
* Created by Dan on 11/20/13.
*/
Run Code Online (Sandbox Code Playgroud)
自定义或删除它的设置在哪里?
根据这个问题,我已经在Android Studio中设置我的项目以使用Square Wire库.
Build
- > Compile Project
工作正常.
2:03:10 PM Compilation completed successfully in 31 sec
Run Code Online (Sandbox Code Playgroud)
但是,如果我打开一个生成的协议缓冲区文件,则无法识别Square包.
另一个症状是,继承自Square Message
类的方法在编辑器中显示为"无法解析方法"编译错误,即使它们构建并运行正常.
我是否需要做更多的事情,而不仅仅是build.gradle
在项目中为我的模块添加依赖项?
我的布局文件定义了一个WebView,下面有一些固定的高度按钮.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:padding="8dp">
<Button
android:text="Decline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0">
</Button>
<Button
android:text="Accept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0">
</Button>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我正在尝试在WebView周围添加填充,就像文本一直运行到UI的边缘一样.
我尝试添加android:padding="8dp"
到WebView,但没有添加填充.我也尝试过paddingLeft和paddingRight,但它们也没有用.
该网页视图 API文档确认它查看,支持继承的android:填充属性,所以我很惊讶这没有奏效.
有人知道这是一个已知的问题,还是我的布局XML的一些互动,我不理解?
仅供参考,我的解决方法是在WebView周围添加额外的LinearLayout,并将填充添加到其中:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:padding="8dp">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我一直在我的应用程序中使用ORMLite,我正在考虑是否转向greenDAO.
性能是该决定的重要组成部分,greenDAO的功能页面说:
对于相同的给定实体,greenDAO插入和更新实体的速度提高了2倍,并且加载实体的速度比ORMLite快4.5倍.
...
(图表和图表更新于10-23-2011)
我认为ORMLite的配置文件生成步骤应该在运行时不需要反射.
ORMLite changlog表明greenDAO基准测试是在配置文件功能发布后完成的,但是greenDAO功能页面没有明确说明是否为测试生成了静态配置文件.
4.26:9/26/2011(svn r1978)
*ANDROID:添加了字段配置实用程序,以避免带注释的Dao创建性能问题.
从那以后,也有ORMLite性能修复,例如
4.40:4/16/2012(svn r2516)
*ANDROID:创建DAO时出现大的性能错误修复.外部字段总是使用反射而不是表格配置.
谁能确认greenDAO和ORMLite之间是否仍有很大的性能差异?谢谢!
我正在尝试将Espresso 2添加到我的项目中(它还有很多其他依赖项),但是在尝试运行测试时我遇到了这个错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/test/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
...
Run Code Online (Sandbox Code Playgroud)
非测试版本工作正常.
有没有人有关于调试此方法的最佳方法的任何提示?
我试过跑./gradlew -q :<my_project>:dependencies
,但我看不出任何明显的问题(虽然我不太了解解释它的输出):
<snip>
androidTestCompile - Classpath for compiling the androidTest sources.
+--- com.squareup.spoon:spoon-client:1.1.2
+--- com.google.dexmaker:dexmaker-mockito:1.0
| +--- com.google.dexmaker:dexmaker:1.0
| \--- org.mockito:mockito-core:1.9.5
| +--- org.hamcrest:hamcrest-core:1.1
| \--- org.objenesis:objenesis:1.0
+--- com.google.dexmaker:dexmaker:1.0
+--- org.mockito:mockito-core:1.9.5 (*)
+--- com.jayway.android.robotium:robotium-solo:5.3.1
+--- com.android.support.test.espresso:espresso-core:2.0
| +--- com.squareup:javawriter:2.1.1
| +--- org.hamcrest:hamcrest-integration:1.1
| | \--- org.hamcrest:hamcrest-core:1.1
| +--- org.hamcrest:hamcrest-library:1.1
| | \--- org.hamcrest:hamcrest-core:1.1
| +--- javax.inject:javax.inject:1
| …
Run Code Online (Sandbox Code Playgroud) java android build.gradle android-gradle-plugin android-espresso
我正在尝试在我的应用程序中使用自定义键盘,但在尝试将其限制为一个特定的UITextField时,我遇到了问题.
我的代码基于这个Xcode项目(最初在这个博客上找到).该代码将自定义UIButton(表示"小数点")添加到UIKeyboardTypeNumberPad键盘视图中.它通过订阅UIKeyboardWillShowNotification并在出现时修改键盘来实现.
Xcode项目工作得很好,但是当我添加一个额外的UITextField时,即使我为该文本字段选择了完全不同的键盘类型,自定义键也会被放入该文本字段的键盘中.
我试图注册只看到来自一个特定UITextField的UIKeyboardWillShowNotification通知,但这似乎不起作用:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:exampleViewController.textField];
Run Code Online (Sandbox Code Playgroud)
我还试图检查传递给keyboardWillShow的NSNotification内部的对象,但不幸的是它指的是键盘,而不是导致键盘出现的UI控件.
2009-10-21 19:50:22.205 Example[6302:207] NSConcreteNotification 0x321ebd0 {name = UIKeyboardWillShowNotification; userInfo = {
UIKeyboardAnimationCurveUserInfoKey = 0;
UIKeyboardAnimationDurationUserInfoKey = 0.300000011920929;
UIKeyboardBoundsUserInfoKey = NSRect: {{0, 0}, {320, 216}};
UIKeyboardCenterBeginUserInfoKey = NSPoint: {160, 588};
UIKeyboardCenterEndUserInfoKey = NSPoint: {160, 372};
Run Code Online (Sandbox Code Playgroud)
}}
我误解了addObserver接口吗?当然必须有一种方法来订阅来自特定UI控件的通知吗?
有没有人对如何实现这一点有任何其他建议?
我一直在关注这个教程上设置Robolectric来测试我的Android摇篮工程.
我一直在遇到这个错误:
android.content.res.Resources$NotFoundException: no such label com.mypackage.dev:string/app_name
Run Code Online (Sandbox Code Playgroud)
通过从教程中下载示例项目,我已经确定问题是我的productFlavors
(dev,staging,production).向工作示例项目添加flavor会导致同样的问题.你可以在这个答案中看到我的build.gradle的大纲.
我已经看到了各种答案(例如这里),这表明我需要sourceSets
为每种味道指定.我已经尝试了很多组合,但不能完全正确.有人可以帮忙吗?
令我困惑的另一件事是我见过的所有Robolectric样本似乎都在为"instrumentTest"指定sourceSets和依赖项,即使Robolectric测试总是只在"test"文件夹中.在我的情况下,我已经在instrumentTest文件夹中进行了Robotium测试,我不明白为什么我需要为Robotium代码添加Robolectric依赖项.
我正在使用Jenkins进行Android持续集成.我有一些独立的,独立的Robotium UI测试,目前需要12分钟才能对单个模拟器进行串行运行.任何人都可以建议一个好的方法来并行运行它们只需要6分钟(或更短)?
我知道在多个设备/模拟器上并行运行完整测试套件的各种方法,例如,请参阅Jenkins Android Emulator插件,Spoon或AppThwack等云测试公司的多配置(矩阵)作业部分.
我知道如何通过使用JUnit注释运行我的测试的特定子集,或者显然Spoon支持类似的功能(请参阅我的问题).
我现在正在使用Spoon来运行我的完整测试套件(主要是为了利用带有屏幕截图的可爱HTML输出).如果有人提供关于拆分测试并将其并行运行的最佳方法的提示,那就太棒了.
我假设我可以通过将测试分成两个单独的CI工作来实现这一点,但是维持两个单独的工作并将结果结合起来听起来很痛苦.
continuous-integration android robotium jenkins android-gradle-plugin
我想使用JMeter来测试通过套接字进行通信的应用程序.它是在java中完成的.在服务器我有典型的
myServerSocket = new ServerSocket(1025);
Run Code Online (Sandbox Code Playgroud)
对于每个连接,线程读取并理解一条线.在客户中,我有典型的
clientSocket = new Socket(hostCM, 1025);
out = new PrintWriter(clientSocket.getOutputStream(), true);
out.println("some bit string here");
Run Code Online (Sandbox Code Playgroud)
我想使用JMeter或任何其他负载测试工具同时发送大量请求并进行压力和负载测试.但我不知道如何准备测试.可以在JMeter中完成吗?
似乎有一些Android设备有光学变焦,例如
有没有办法以编程方式检测这个?
由于相机通常需要几秒钟来初始化,在我的应用程序中有一些流程我启动相机预期用户即将使用它(因此应用程序感觉更快,当他们实际按下我的应用内相机按钮) .如果相机具有光学变焦,那么我不想这样做,因为镜头滑出并使用户烦恼.
如果我必须将这些设备列入黑名单,是否有人知道所有带有光学变焦的Android设备的列表,最好是使用他们的Build.MANUFACTURER和Build.PRODUCT字符串?
如果它有帮助,这里是我最近购买的S4 Zoom的Camera.Parameters:
{preferred-preview-size-for-video=704x528, factory-af-led-lv-limit=-1,-1, zoom=0, factory-af-scan-limit=-1,-1, max-num-detected-faces-hw=0, continuous-mode=off, zoom-supported=true, metering=center, whitebalance=auto, scene-mode=auto, jpeg-quality=1, factory-testno=0, factory-af-diff-check=-1,-1, preview-format-values=yuv420sp,yuv420p, best-mode=off, red-eye-fix=fail, jpeg-thumbnail-quality=100, preview-format=yuv420sp, low-light-mode=off, zoom-action=zoom-stop, face-detection=off, video-size-values=1920x1080,1280x720,800x450,768x512,640x480,320x240,176x144, factory-zoom-slope-check-data=-1,-1, preview-size=960x540, focal-length=4.300000, flash-charging=0, factory-cap-range=-1,-1, factory-iris-range=-1,-1, flash-mode-values=off,auto,red-eye,on,fillin,slow,red-eye-fix, preview-frame-rate-values=30,15, factory-af-scan-range=-1,-1, max-num-metering-areas=0, preview-frame-rate=30, focus-mode-values=auto,infinity,macro,fixed,face-detection,continuous,continuous-picture,continuous-video,manual,multi,touch,object-tracking, jpeg-thumbnail-width=224, video-size=0x0, scene-mode-values=auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight,dusk-dawn,fall-color,back-light,text, preview-fps-range-values=(7000,30000), jpeg-thumbnail-size-values=224x126,160x120,192x128,0x0, zoom-ratios=100,120,140,160,180,220,310,420,560,790,1000, preview-size-values=960x540,768x512,704x576,704x528,640x524,640x480,320x240, smart-scene-detection=0, factory-zoom-range-check-data=-1,-1, factory-af-led-range=-1,-1,-1,-1, picture-size-values=4608x2592,3264x2448,4608x3456,4608x3072,4096x2304,3960x2640,3648x2736,2592x1944,2304x1728,1984x1488,1920x1080,1024x768,960x720,640x480, preview-fps-range=7000,30000, auto-whitebalance-lock=false, min-exposure-compensation=-6, antibanding=off, max-num-focus-areas=1, vertical-view-angle=46.3, factory-wb-value=-1,-1,-1,-1, zoom-ring=-1, horizontal-view-angle=67, video-stabilization-supported=false, jpeg-thumbnail-height=126, continuous-fps=, focus-mode=auto, factory-sc-speedtime=-1,-1, factory-gyro-range-data=-1,-1,-1,-1, auto-whitebalance-lock-supported=true, video-frame-format=yuv420sp, max-num-detected-faces-sw=0, …
Run Code Online (Sandbox Code Playgroud) android ×6
build.gradle ×2
gradle ×2
java ×2
greendao ×1
iphone ×1
jenkins ×1
jmeter ×1
keyboard ×1
ormlite ×1
padding ×1
performance ×1
robolectric ×1
robotium ×1
sockets ×1
sqlite ×1
square-wire ×1
uitextfield ×1