小编Fig*_*gör的帖子

在Lua中创建函数

当我通过分配创建函数时,"if"条件不起作用,但是当我创建函数时,如下面的第二个示例,它可以工作.你能告诉我为什么吗?

不工作:

local start=os.time()

local countDown = function(event)
   if((os.time()-start)==3) then
      Runtime: removeEventListener("enterFrame", countDown)
   end
   print(os.time()-start)
end

Runtime:addEventListener("enterFrame", countDown)
Run Code Online (Sandbox Code Playgroud)

工作:

local start=os.time()

local function countDown(event)
   if((os.time()-start)==3) then
      Runtime: removeEventListener("enterFrame", countDown)
   end
   print(os.time()-start)
end

Runtime:addEventListener("enterFrame", countDown)
Run Code Online (Sandbox Code Playgroud)

lua function coronasdk

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

Android AutoCompleteTextView DropDown位置

我使用以下代码进行自动完成,但下拉项目位于上方AutoCompleteTextView.我希望它出现在AutoCompleteTextView.我怎样才能做到这一点?

package com.example.autocomplete;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class MainActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.activity_main);

         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                 android.R.layout.simple_list_item_1, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
     }

     private static final String[] COUNTRIES = new String[] {
         "Belgium","Belgam","Bellam", "France Belgium", "Italy", "Germany", "Spain"
     };
 }
Run Code Online (Sandbox Code Playgroud)

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <AutoCompleteTextView
        android:id="@+id/countries_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="100dp"
        android:dropDownHeight="100dp"
        android:ems="10"
        android:text="AutoCompleteTextView" >

        <requestFocus />
    </AutoCompleteTextView> …
Run Code Online (Sandbox Code Playgroud)

android autocompletetextview

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

Admob Security Exception:Permission Denial

我点击我的AdView并在Play商店中打开阿里巴巴应用页面,然后安装它.之后,当我点击AdView时,我开始收到此错误并且我的应用程序崩溃了.卸载这个阿里巴巴应用程序后,我可以点击并查看广告.

现在我很好奇为什么会这样?

Caused by java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=https://www.googleadservices.com/... flg=0x10000000 cmp=com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity } from ProcessRecord{800f07c 11735:com.figengungor.konuscevir/u0a452} (pid=11735, uid=10452) not exported from uid 10256
Run Code Online (Sandbox Code Playgroud)

这是我的完整崩溃报告:

Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.figengungor.konuscevir/com.google.android.gms.ads.AdActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=https://www.googleadservices.com/... flg=0x10000000 cmp=com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity } from ProcessRecord{800f07c 11735:com.figengungor.konuscevir/u0a452} (pid=11735, uid=10452) not exported from uid 10256
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2787)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1504)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6247)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:872)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:762)
arrow_drop_down
Caused by java.lang.SecurityException: …
Run Code Online (Sandbox Code Playgroud)

android admob adview

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

相同的字段有两种不同的类型给改造2的Gson转换器带来麻烦

这是json架构:

在此输入图像描述

如您所见,rating可以是boolean和object.

我正在使用Retrofit 2和Gson转换器.我该如何为这个模式创建我的模型?

android gson retrofit2

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

如何将文件设置为 Android 10 的铃声?

我曾经使用以下代码将原始声音文件保存到外部存储并将其设置为铃声。但事情似乎在 android 10 中发生了变化。你能帮助我或向我展示一些如何更新我的代码以使用 android 10 的指南吗?

这是将文件保存到外部存储的代码:

保存文件:

String path = Environment.getExternalStorageDirectory() + "/customsounds";

 public File getFile() {
        boolean exists = (new File(path).exists());
        if (!exists) {
            new File(path).mkdirs();
        }
        File newSoundFile = new File(path, sound.getFileName() + ".mp3");
        Uri mUri = Uri.parse("android.resource://com.example.customsounds/" + sound.getId());
        ContentResolver mCr = getContentResolver();
        AssetFileDescriptor soundFile;
        try {
            soundFile = mCr.openAssetFileDescriptor(mUri, "r");
        } catch (FileNotFoundException e) {
            soundFile = null;
        }

        try {
            byte[] readData = new byte[1024];
            FileInputStream fis = soundFile.createInputStream();
            FileOutputStream fos = new …
Run Code Online (Sandbox Code Playgroud)

android ringtone android-storage android-10.0

6
推荐指数
3
解决办法
4276
查看次数

Ebp,esp和堆栈框架与nasm组装

我在下面的代码中有一些关于ebp,esp和stack frame的问题.

  1. 为什么我们从esp中减去28?我们在main中有两个局部变量x和y.那么为什么我们不减8?

  2. 我们不是把值从右到左叠加?那么为什么我们在[eax + 8]而不是[eax + 4]中添加1?

  3. 我对这个结构有点困惑.你能帮我吗?谢谢.

    func(int a, int b, int c)
    {
      return a+b+c;
    }
    main()
    {
     int x, y=3;
     x=func(y,2,1);
    }
    
    Run Code Online (Sandbox Code Playgroud)

在Assembly中传递参数

assembly nasm stack-frame

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

如何在GLPK中为我的变量写一个if条件?

这是我的完整问题:

在此输入图像描述

信息:

*最大.总投资:125美元

*支付是购买的单位x支付/单位的总和

*每次投资成本:购买成本+成本/单位x如果您购买至少一个单位的单位数量

*费用是每笔投资的总和

约束:

*您可能不会同时投资2和5.

*只有投资2和3中的至少一个,您才可以投资1.

*您必须至少投资3,4,5中的两个.

*您的投资额不得超过最大单位数.

问题:最大化利润:支付 - 成本

 xi: # of units i ? {1,2,3,4,5}
 yi=1 if xi>0 else yi=0
 cost = sum{i in I} buyInCost_i * yi + cost-unit_i*xi
 pay-off = sum{i in I} (pay-off/unit)_i*xi
 profit = pay-off - cost

 Maximize profit

 Subject to

 y2+y5 <= 1
 y1<= y2+y3
 y3+y4+y5 >= 2
 x1<=5, x2<=4, x3<=5, x4<=7, x5<=3
 cost<=125
Run Code Online (Sandbox Code Playgroud)

这是我的问题:

例如,我有这个二进制变量y

 yi=1 if xi>0 else yi=0  and i ? {1,2,3,4,5}
Run Code Online (Sandbox Code Playgroud)

我宣称我是一个数据集

 set I;

 data; …
Run Code Online (Sandbox Code Playgroud)

linear-programming glpk mathprog

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

如何为 SliverGrid 提供背景颜色?

For ListView or GridView we wrap it with Container. But how can I give background color to SliverGrid?

flutter flutter-sliver sliver-grid

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

如何在Python中进行区分大小写的字符串比较?

我正在尝试编写一个比较两个字符串的代码,如果找到匹配除了大写字母的区分大小写的条件,则返回字符串.这是我写的函数,我已经知道==非常适合比较区分大小写.然而,它仍然打印1月的最后一个测试线,这是预期的.那你可以帮帮我吗?

  months = ['January',
      'February',
      'March',
      'April',
      'May',
      'June',
      'July',
      'August',
      'September',
      'October',
      'November',
      'December']

  def valid_month(month):
     for x in months:
         if x==month.capitalize() :
             print x
Run Code Online (Sandbox Code Playgroud)

测试代码:

  valid_month("january")  
  valid_month("January")
  valid_month("foo") 
  valid_month("") 
  valid_month("jaNuary")
Run Code Online (Sandbox Code Playgroud)

python string

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

如何完成最多一项特定活动的活动?

例如,我打开了活动 A、B、C、D。

我想完成 D 和 C 并返回 B。

我不想打开带有明确任务和新任务标志的活动 B。我也想保留活动 A,以便用户可以使用后退按钮从 B 返回到 A。

我怎样才能做到这一点?

android back activity-finish android-activity

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