小编vau*_*uge的帖子

Android与Eclipse - 等待HOME('android.process.acore')推出?

当我尝试使用Eclipse运行Hello World应用程序时,控制台显示"正在等待HOME('android.process.acore')启动...",但即使我等了半个小时,也没有任何事情发生,除了模拟器在黑色背景上显示"Android"-logo.当我尝试通过AVD Manager直接启动模拟器时也会发生同样的情况.PATH变量设置正确,我已经安装了eclipse和Android SDK的最新版本.

这可能是导致这种情况发生的原因?

谢谢!

eclipse android

13
推荐指数
2
解决办法
2万
查看次数

Android编程:如何在矩形中绘制多行文字?

我看过很多关于类似问题的帖子,但没有一个对我有用.在Canvas,我有一个大小的矩形,比方说,200px到200px,我想在这个矩形中写文字.文本不需要填充整个矩形,但重要的是当到达矩形的末尾时应该自动换行.我怎样才能在Android中执行此操作?

android android-layout android-canvas

9
推荐指数
1
解决办法
8672
查看次数

C编程:如何找到最短路径?

想象一下,我有一个由36个顶点组成的6x6正方形(即每行6个顶点和每列6个顶点),看起来像这样:

•  •  •  •  •  •  
•  •  •  •  •  •  
•  •  •  •  •  •  
•  •  •  •  •  •  
•  •  •  •  •  •  
•  •  •  •  •  •
Run Code Online (Sandbox Code Playgroud)

每个顶点都与1,2,3或4个近邻点连接 - 所以我们基本上得到一个带有顶点和边的图.我的问题如下:我想要一个机器人通过那个"迷宫"的边缘,直到找到某个顶点放置某个物体.一旦找到该对象,就应该以最快的方式回到起点.

现在,我不太清楚如何实现这一点,所以我的问题是:在C中保存有关顶点和边的信息的最佳结构是什么?(邻接矩阵对我来说似乎效率低,因为36x36非常大).而且,使用这些信息,我怎样才能找到最快的方式?

c path adjacency-matrix

5
推荐指数
1
解决办法
792
查看次数

Android:内存不足错误

当我将Android应用程序最小化大约4或5次时,我总是会收到以下错误:

02-01 19:24:11.980: E/dalvikvm-heap(22362): Out of memory on a 3686416-byte allocation.
02-01 19:24:12.000: E/dalvikvm(22362): Out of memory: Heap Size=62755KB, Allocated=55237KB, Limit=65536KB
02-01 19:24:12.000: E/dalvikvm(22362): Extra info: Footprint=62435KB, Allowed Footprint=62755KB, Trimmed=2144KB
02-01 19:24:12.000: E/Bitmap_JNI(22362): Create Bitmap Failed.    
02-01 19:24:12.000: E/Bitmap_JNI(22362): Failed to create SkBitmap!
02-01 19:24:12.000: E/AndroidRuntime(22362): FATAL EXCEPTION: main
02-01 19:24:12.000: E/AndroidRuntime(22362): java.lang.OutOfMemoryError: (Heap Size=62755KB, Allocated=55237KB)
02-01 19:24:12.000: E/AndroidRuntime(22362):    at android.graphics.Bitmap.nativeCreateScaledBitmap(Native Method)
02-01 19:24:12.000: E/AndroidRuntime(22362):    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:744)
02-01 19:24:12.000: E/AndroidRuntime(22362):    at de.vauge.mb.Utils.getResizedBitmap(Utils.java:56)
02-01 19:24:12.000: E/AndroidRuntime(22362):    at de.vauge.mb.MenuView.initialize(MenuView.java:74)
02-01 19:24:12.000: E/AndroidRuntime(22362): …
Run Code Online (Sandbox Code Playgroud)

memory heap android bitmap

4
推荐指数
1
解决办法
2万
查看次数

long int太大而无法转换为float

假设我有一个带有该功能的程序

def fakultaet(x):
    if x>1:
        return(x* fakultaet(x-1)) 
    else:
        return(1)
Run Code Online (Sandbox Code Playgroud)

返回给定数字的阶乘,我需要计算

1.0/fakultaet(200)
Run Code Online (Sandbox Code Playgroud)

但我得到一个溢出错误:long int too large to convert to float.

我怎么解决这个问题?

python casting

2
推荐指数
1
解决办法
4560
查看次数

Spring:已经为此响应调用了 getOutputStream()

我知道还有很多其他帖子处理同样的错误,但所有这些帖子要么是关于 JSP/GSP 页面的,要么是出于任何其他原因对我来说不是很有帮助。我正在使用带有 Thymeleaf 的 Spring MVC。以下函数用于下载文件。

@RequestMapping(value = "/test/download/*", method = RequestMethod.GET)
public String getFile(HttpServletResponse response)
{

    ServletOutputStream stream = null;
    try
    {
        stream = response.getOutputStream();

        MultipartFile f = test.getFile();

        InputStream is = f.getInputStream();
        IOUtils.copy(is, stream);
        response.flushBuffer();

        stream.flush();
        stream.close();

    } catch(Exception ex)
    {

    }

    return "test";

}
Run Code Online (Sandbox Code Playgroud)

它确实有效,所以问题不大,但在控制台中,我总是收到以下错误:

2014-01-10T09:28:09.053+0100  SEVERE  Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception  [Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause …
Run Code Online (Sandbox Code Playgroud)

java spring outputstream illegalstateexception

2
推荐指数
1
解决办法
4万
查看次数

libGDX:3d动画无效

我使用Blender和fbxconv创建了一个.g3db动画文件.现在,我的libGDX项目源代码看起来像这样:

public class test implements ApplicationListener {
// ...
 public ModelInstance fred
 public AnimationController animationController;

 public void create () {
    modelBatch = new ModelBatch();
    // ... 

    assets = new AssetManager();
    assets.load("data/fred.g3db", Model.class);
    loading = true;
 }

 private void doneLoading() {
    Model fredData = assets.get("data/fred.g3db", Model.class);

    fred = new ModelInstance(fredData);
    animationController = new AnimationController(fred);
    animationController.animate(fred.animations.get(0).id, -1, 1f, null, 0.2f);

    loading = false;
 }

 public void render () {
    if (loading && assets.update())
        doneLoading();
    camController.update();

    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); …
Run Code Online (Sandbox Code Playgroud)

java 3d animation libgdx

1
推荐指数
1
解决办法
2546
查看次数

如何在类中使函数可变?

想象一下,我有一堂课

class A {
 int a;
 int b;

 A(int a, int b) {
  this.a=a; this.b=b;
 }

 int theFunction() {
   return 0;
 }

 void setTheFunction([...]) {
    [...]
 }
}
Run Code Online (Sandbox Code Playgroud)

对于我实例化的每个新对象,我希望能够theFunction()通过调用以新的方式定义setTheFunction( [...] ).例如,我想做这样的事情:

A test = new A(3,2);
test.setTheFunction ( int x = a*b; return x*x+2; );
System.out.println(test.theFunction()); // Should return (3*2)*(3*2)+2 = 38
Run Code Online (Sandbox Code Playgroud)

或类似的东西:

A test2 = new A(1,5);
test.setTheFunction ( for(int i=0; i<b; i++) a=a*b*i; return a; );
Run Code Online (Sandbox Code Playgroud)

现在,我当然可以做的是在A类中编写所有这些函数,并使用switch语句来确定要选择哪一个.但是,如果我不想theFunction()在我的A类内部硬编码算法,有没有办法做类似上面的事情?而且会是什么setTheFunction()模样?你必须通过什么类型的论证?

java

0
推荐指数
1
解决办法
119
查看次数