当我尝试启动我的AndEngine活动时,我收到此错误:
ERROR/InputDispatcher(21374): channel '4122e148 my.package.AcGame (server)' ~ Channel is unrecoverably broken and will be disposed!
Run Code Online (Sandbox Code Playgroud)
该应用程序不会崩溃,但有一个黑屏,设备不会按下"后退"或"主页"按钮.
有谁知道问题是什么?
有人知道如何将多行代码段添加到Google地图标记吗?这是我添加标记的代码:
map.getMap().addMarker(new MarkerOptions()
.position(latLng()).snippet(snippetText)
.title(header).icon(icon));
Run Code Online (Sandbox Code Playgroud)
我想要片段看起来像这样:
| HEADER |
|foo |
|bar |
Run Code Online (Sandbox Code Playgroud)
但是当我试图将snippetText设置为"foo \n bar"时,我看到了foo bar
,我没有任何想法如何使它成为多线.你能帮助我吗?
如何让用户编辑TextView
?当然,我可以使用EditText
,但我不知道如何自定义它,我也读过TextView
可以编辑的Android文档.所以我尝试了这个:
<TextView android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="80sp"
android:text="MyText"
android:editable="true"
android:singleLine="true"
android:inputType="text"
android:focusable="true"
android:clickable="true"
android:cursorVisible="true"/>
Run Code Online (Sandbox Code Playgroud)
但它看起来仍然很常见TextView
.有谁知道我错过了什么?或者,可能是,如何定制EditText
它看起来像TextView
:没有边框和背景?
我尝试使用Maven将我的应用程序部署到Tomcat,我发现了这个示例.
这是我的pom.xml的片段:
<!-- Maven Tomcat Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/</url>
<server>TomcatServer</server>
</configuration>
</plugin>
<!-- Maven compiler plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我跑步时,tomcat:deploy
我得到这个错误:Cannot invoke Tomcat manager: Connection refused
.这是完整的堆栈跟踪:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project webapp: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project webapp: Cannot invoke Tomcat manager
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at …
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过Marketplace在Eclipse Helios中安装Maven集成插件,但我收到"无法满足依赖"错误:
Cannot complete the install because one or more required items could not be found.
Software being installed: m2e - Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.feature.feature.group 1.4.0.20130601-0317)
Missing requirement: async-http-client 1.6.5.20130531-2315 (com.ning.async-http-client 1.6.5.20130531-2315) requires 'package org.slf4j 1.6.2' but it could not be found
Cannot satisfy dependency:
From: Maven Archetype Common Bundle 1.4.0.20130531-2315 (org.eclipse.m2e.archetype.common 1.4.0.20130531-2315)
To: bundle org.eclipse.m2e.maven.runtime [1.4.0,1.5.0)
Cannot satisfy dependency:
From: m2e - Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.feature.feature.group 1.4.0.20130601-0317)
To: org.eclipse.m2e.archetype.common [1.4.0.20130531-2315]
Cannot satisfy dependency:
From: Embedded …
Run Code Online (Sandbox Code Playgroud) 我有一个程序执行长时间的计算,所以我想加快其性能.所以我此刻尝试启动3个线程,但java.exe
仍然占用CPU使用率的25%(因此,只使用了一个CPU),即使我尝试使用.setPriority(Thread.MAX_PRIORITY);
并设置java.exe
实时优先级(24),它仍然存在.我尝试使用,RealtimeThread
但似乎它的工作速度更慢.如果将每个线程分配给一个处理器并且总CPU使用率增加到75%,那将是完美的,但我不知道该怎么做.这就是我的代码现在的样子:
Thread g1 = new MyThread(i,j);
g1.setPriority(Thread.MAX_PRIORITY);
g1.run();
Thread g2 = new MyThread(j,i);
g2.setPriority(Thread.MAX_PRIORITY);
g2.run();
Thread g3 = new MyThread(i,j);
g3.setPriority(Thread.MAX_PRIORITY);
g3.run();
if (g1.isAlive()) {
g1.join();
}
if (g2.isAlive()) {
g2.join();
}
if (g3.isAlive()) {
g3.join();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从数据库中选择一些数据,我有两片代码来做:
cursor = builder.query(db,
new String[]{"col1", "col2", "col3"},
"id = ?", new String[]{getSID(db)}, null, null, null);
Run Code Online (Sandbox Code Playgroud)
和
cursor = builder.query(db,
new String[]{"col1", "col2", "col3"},
"id = " + getSID(db), null, null, null, null);
Run Code Online (Sandbox Code Playgroud)
它们之间的区别在于,根据文档,第一个似乎更正确,但它也不起作用 - 光标是空的.而不是第二个 - 我得到了我需要的所有数据.
所以我尝试在我的电脑上使用数据库副本执行不同的SQL查询,这就是我所拥有的:
SELECT col1, col2, col3 FROM SomeTables WHERE (id = '42')
Run Code Online (Sandbox Code Playgroud)
这个不起作用(这个查询显然等于查询,由第一个代码示例生成)
SELECT col1, col2, col3 FROM SomeTables WHERE (id = 42)
Run Code Online (Sandbox Code Playgroud)
这个工作正常(等于从第二个代码示例查询).
据我所知,SQLite应该自动执行类型转换,但出了点问题,我不知道为什么.您对如何修复第一个代码示例有什么想法吗?(或者,也许,数据库?)
如果重要的话,这里是CREATE
带有id
字段的表的简化脚本:
CREATE TABLE SomeTable ( ID PRIMARY KEY, col1, col2, [...] )
Run Code Online (Sandbox Code Playgroud)
UPD:顺便说一下,getSID(db)返回String …
我尝试使用片段和objectAnimator来制作这里的翻转动画,并且在Android 4.1上一切正常,但是当我尝试添加时android-support-v13. jar
,使用FragmentActivity并在旧版本上启动它,片段之间的动画会使应用程序崩溃并出现此错误:
java.lang.RuntimeException: Unknown animation name: objectAnimator
Run Code Online (Sandbox Code Playgroud)
请问,您能说我如何使用objectAnimator或如何使用常见的Android动画创建翻转动画?
UPD:我也尝试过使用http://nineoldandroids.com/,但我无法理解它如何用于活动过渡动画.
我尝试以这种方式挂载扩展文件:
final StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
String obbPath = Environment.getExternalStorageDirectory() + "/Android/obb";
final String obbFilePath = obbPath + "/com.example/main.1.com.example.obb";
storageManager.mountObb(obbFilePath, "SecretKey", new OnObbStateChangeListener() {
@Override
public void onObbStateChange(String path, int state) {
super.onObbStateChange(path, state);
if (state == OnObbStateChangeListener.MOUNTED) {
onObbMounted();
} else {
Log.d("##", "Path: " + path + "; state: " + state);
}
}
});
Run Code Online (Sandbox Code Playgroud)
但是在运行时我得到状态21:ERROR_COULD_NOT_MOUNT:
Path: /storage/sdcard0/Android/obb/com.example/main.1.com.example.obb; state: 21
Run Code Online (Sandbox Code Playgroud)
我添加了这个:
File f = new File(obbFilePath);
if (!f.exists()) {
Log.e("OBB", "FILE NOT FOUND!!!");
}
Run Code Online (Sandbox Code Playgroud)
而logcat说该文件存在.我不知道,为什么我能得到这个状态21?
这就是我试图这样做的方式:
fontTextureAtlas = new BitmapTextureAtlas(1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
font = FontFactory.createFromAsset(fontTextureAtlas,this,"times.ttf",45f,true,Color.WHITE);
getEngine().getTextureManager().loadTexture(fontTextureAtlas);
Run Code Online (Sandbox Code Playgroud)
然后,在代码中:
Text text = new Text(10,10, font,"Some text");
scene.attachChild(text);
Run Code Online (Sandbox Code Playgroud)
而我所看到的就是这个:
我也尝试使用new Font(fontTextureAtlas,Typeface.DEFAULT,45f,true,Color.WHITE);
初始化font
,但结果几乎相同.
有谁知道我做错了什么?