问题列表 - 第45691页

在android教程应用程序上制作图像全屏

使用Hello,World Gridview教程示例,我试图在单击时使图像全屏,而不是在数组中显示图像的位置.由于我对Android不熟悉,这是我第一次尝试使用它,我很茫然.我虽然熟悉Java,但我尝试过这样的事情(显然不起作用):

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(new ImageAdapter(this));

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            showImage(v, position);
            Toast.makeText(HelloAndroid.this, "" + parent.getId(), Toast.LENGTH_SHORT).show();
        }
    });
}

private void showImage(View view, int position) {
    ImageView imgView = (ImageView) view; 
    imgView.setImageResource(position);     
}
Run Code Online (Sandbox Code Playgroud)

但应用程序崩溃(强制关闭).有任何想法吗?

这是我正在使用的教程应用程序

android imageview

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

使用连接池处理活动记录超时的正确方法是什么?

我已经跟踪了一个奇怪的错误,undefined method `run_callbacks' for nil:NilClass并且能够使用此示例代码重现它.

基本上问题是活动记录正在超时(默认为5s)但抛出一个未定义的方法异常,这对我来说似乎不对.

但无论如何,处理这个问题的正确方法是什么?在我的真实代码中,我有一堆忙于做实际工作的线程但偶尔会遇到这个错误.所以想象一下,这puts是真正的代码.我希望现有的线程在发生这种情况时继续工作.

threads = []
10.times do |n|

 threads <<  Thread.new {
    ActiveRecord::Base.connection_pool.with_connection do |conn|
      puts "#{n} #{conn}"
      res =  conn.execute("select sleep(6)", :async => true)
    end
  }
end

# block and wait for all threads to finish
threads.each { |t| puts "joined" ; t.join }
rescue Exception => e
  puts  $!, $@
end
Run Code Online (Sandbox Code Playgroud)

如果我按原样运行此代码,我会得到异常.如果我将睡眠减少到4s,我就不会.这是6s睡眠的输出.

joined
0 #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0xb73c6380>
1 #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0xb73c5548>
2 #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0xb73c4fe4>
3 #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0xb73c4a80>
4 #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0xb73c451c>
joined
joined
joined
joined
joined
undefined …
Run Code Online (Sandbox Code Playgroud)

mysql activerecord multithreading exception-handling ruby-on-rails

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

是否有一个与SBCL的运行程序相当的Scheme?

我可以(run-program "/usr/ls" '())在SBCL中运行.在任何Scheme实现中是否存在等价物?

lisp scheme sbcl common-lisp chicken-scheme

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

HTML 5 Canvas中的鼠标位置

我正在编写一个简单的绘图应用程序来了解HTML 5画布.问题是我似乎无法在canvas元素中获得正确的鼠标位置.我已经查看了stackoverflow上的其他问题,就像在这里用javascript在画布获取鼠标位置来解决这个问题,但是他们的解决方案没有好像在帮助我.

这是我的代码:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Untitled Document</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
        <style type="text/css">
            #test {
                border: solid black 1px;
                width: 500px;
                height: 500px;
            }
        </style>
        <script type="text/javascript">
            $(function(){
                var canvas=document.getElementById('test');
                if(canvas.getContext){
                    var ctx =canvas.getContext('2d');       
                    var draw = false;
                    ctx.strokeStyle = "rgb(200,0,0)";
                    ctx.lineWidth = 3;
                    ctx.lineCap = "round"; 

                    $('#test').mousedown(function(){draw=true;});
                    $('#test').mouseup(function(){draw=false;});
                    $('#test').mousemove(function(e){
                        if(draw){
                            var x , y;
                            x = e.layerX;
                            y = e.layerY;
                            ctx.moveTo(x,y);
                            ctx.lineTo(x+1,y+1);
                            ctx.stroke();
                                             }
                                    });
                }
            });
        </script>
    </head>
    <body> …
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas

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

PayPal AdaptivePayments PaymentDetail PayKey

我正在使用PayPal Pay API,具有自适应(链式)付款.我试图将用户转发到paypal,然后回到我预定义的return_url.

问题是:我需要在return-url中有一个PayKey.原因是:我需要调用PaymentDetail API来审核return_url中的付款.并且,我不想使用IPN,因为我需要在返回的Url上使用某些令牌进行验证.

我遇到的问题是:PayKey正在使用所有参数生成,包括return-url(因此在我构建实际数组之后,我从中得到我的$响应.我不能将PayKey放在return-Url中因为此时尚未生成.

  //Create request payload with minimum required parameters
  $bodyparams = array ("requestEnvelope.errorLanguage" => "en_US",
                       "actionType" => "PAY",
                       "currencyCode" => "USD",
                       "cancelUrl" => "http://www.paypal.com", 
                       "returnUrl" => $return_url . "&payKey=${payKey}",  **// Does not work - PAYKEY NEEDED TO ADD???**
                       "receiverList.receiver(0).email" => "account1@hotmail.com", //TODO
                       "receiverList.receiver(0).amount" => $price, //TODO
                       "receiverList.receiver(0).primary" => "true", //TODO
                       "receiverList.receiver(1).email" => "account2@hotmail.com", //TODO
                       "receiverList.receiver(1).amount" => $receiver_gets, //TODO
                       "receiverList.receiver(1).primary" => "false" //TODO
                       );

   // convert payload array into url encoded query string
   $body_data = http_build_query($bodyparams, "", …
Run Code Online (Sandbox Code Playgroud)

php paypal paypal-adaptive-payments

6
推荐指数
2
解决办法
3930
查看次数

如何获取函数的名称?

是否有可能知道函数的名称?

main()->    
  myFunction().

myFunction()->
  io:write("I am ~s !",[????]).
Run Code Online (Sandbox Code Playgroud)

erlang

18
推荐指数
2
解决办法
2651
查看次数

无法将存储库添加到本地settings.xml

当我在.m2/settings.xml文件中指定我的存储库时,我无法让Maven下载依赖项.但是,当我将存储库名称添加到我的pom时,Maven会下载这些依赖项.

具体来说,我正在尝试编译一些hibernate示例项目,并且我已经在说明中读到了我应该将以下存储库添加到我的pom或settings.xml中:

    <repositories>
        <repository>
          <id>jboss-public-repository-group</id>
          <name>JBoss Public Repository Group</name>
          <url>http://repository.jboss.org/nexus/content/groups/public/</url>
          <layout>default</layout>
          <releases><enabled>true</enabled><updatePolicy>never</updatePolicy></releases>
          <snapshots><enabled>true</enabled><updatePolicy>never</updatePolicy></snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>jboss-public-repository-group</id>
            <name>JBoss Public Repository Group</name>
            <url>http://repository.jboss.org/nexus/content/groups/public/</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
        </pluginRepositories>    
Run Code Online (Sandbox Code Playgroud)

当我将片段放在项目的pom.xml中时,一切正常,但是当我尝试将它放在settings.xml中时,我收到此错误:

org.hibernate的POM:hibernate-core:jar:3.6.1.Final缺失,没有可用的依赖信息

我有什么想法可能做错了吗?

maven-3 maven

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

344
推荐指数
6
解决办法
30万
查看次数

如何释放仅包含指针的结构

我有一个结构,你看到如下:

typedef struct _List {
    Person *person; // pointer for people list
    DoList *do; // Kinda timer, for checking list in some intervals
} List;
Run Code Online (Sandbox Code Playgroud)

有没有必要释放这个结构?如果是这样,我怎么能释放它?

c free struct typedef

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

Vibrator.vibrate()抛出ArrayIndexOutOfBoundsException

我使用以下代码片段以特定模式振动手机,但它会抛出和ArrayIndexOutOfBoundsException.

vibrator.vibrate(new long[] { selectedDuration, CONSTANT_DELAY }, REPEAT); 
Run Code Online (Sandbox Code Playgroud)

vibrator.vibrate(VIBRATE_DURATION);
Run Code Online (Sandbox Code Playgroud)

工作良好.有什么指针吗?

android exception vibration

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