小编Gui*_*osa的帖子

平板电脑上无法打开设置活动

我已经正确设置了pref_general,它的值以及运行intent的代码:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        Intent intecao = new Intent(characterList.this, SettingsActivity.class);
        startActivity(intecao);
        return true;
    }

    return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)

因此,如果我点击选项弹出窗口中的设置,它将在我的手机/ 7"平板电脑中正确打开,但对于更大的平板电脑,如9"或更多,它会给我一个空白的屏幕弹出窗口,而不会写任何内容,例如如下:

在此输入图像描述

我该如何解决这个问题?导致这种情况发生的问题是什么?

---编辑---

这是我的pref_general:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:title="Made by Megafuji and Kintups"/>

    <ListPreference
        android:key="console1"
        android:title="Console"
        android:summary="Select your console" …
Run Code Online (Sandbox Code Playgroud)

android android-settings

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

如何让Visual Studio 2013 dlls依赖项落后?

我的应用程序在其他计算机上打开时会出现错误msvcr"something".dll,我发现要解决此问题需要安装以下内容:http: //www.microsoft.com/en-us/download/details的.aspx?ID = 40784

这是Visual Studio 2013的Visual C++ Redistributable Packages.

我想用可执行文件中的dll编译程序,这样的事情可能吗?

如果不可能,我在哪里可以将所有dll放入已编译的项目文件夹中?

c++ visual-studio-2013

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

与Python相比,C#中的OpenCV MatchTemplate太慢了

我已经在Python中编写了一个解决方案,该解决方案效果很好,但是需要安装几个库以及许多专业设置才能工作.我决定在Visual Studio Community 2017上使用C#中的GUI构建它,但在第一个成功的函数中,结果比Python慢​​.哪个IMO实际上应该更快.

代码本质上只是在大海捞针图像搜索中,通过从文件夹中获取所有图像并在大海捞针中测试每个针(总共60个图像),在python中我返回字符串,但在C#中我只是打印.

我在Python中的代码如下:

def getImages(tela):
    retorno = []
    folder = 'Images'
    img_rgb = cv2.imread(tela)
    for filename in os.listdir(folder):
        template = cv2.imread(os.path.join(folder,filename))
        w, h = template.shape[:-1]
        res = cv2.matchTemplate(img_rgb, template, cv2.TM_CCOEFF_NORMED)
        threshold = .96
        loc = np.where(res >= threshold)
        if loc[0]>0:
            retorno.append(filename[0]+filename[1].lower())
            if len(retorno)> 1:
                return retorno
Run Code Online (Sandbox Code Playgroud)

在C#中:

Debug.WriteLine(ofd.FileName);
Image<Bgr, byte> source = new Image<Bgr, byte>(ofd.FileName);
string filepath = Directory.GetCurrentDirectory().ToString()+"\\Images";
DirectoryInfo d = new DirectoryInfo(filepath);
var files = d.GetFiles();
foreach (var fname in files){
    Image<Bgr, byte> template = …
Run Code Online (Sandbox Code Playgroud)

.net c# python image-processing image-recognition

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

如何设置Android模拟GPS位置?

描述

我在尝试使用 Android 模拟位置时遇到问题,我的主要目标是将 Android GPS 设置为认为我们处于不同的位置,又名假 GPS。

目前的尝试

我目前尝试了两种不同的类似解决方案,可在这两个网站上找到:

这两个教程都是 2012 年的,我不知道它们是否已经过时,或者我很难实施它们。

编码开发

首先我确保我有权限:

  1. ACCESS_COARSE_LOCATION
  2. ACCESS_FINE_LOCATION
  3. ACCESS_MOCK_LOCATION *

注意:1 和 2 都被检查,如果它们不可用,我使用requestPermissions函数请求许可。第三个是无法询问的,实际上只能在调试模式下通过AndroidManifest.xml添加。

我还确保在“设置”>“开发人员选项”>“允许模拟位置”中选择了我的应用程序。

毕竟,我已经尝试通过 OnCreate 方法或 OnClick 按钮调用这个函数:

public void mockLocation(){
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy( Criteria.ACCURACY_FINE );
    String mocLocationProvider = lm.getBestProvider( criteria, true );
    if ( mocLocationProvider == null ) {
        Toast.makeText(getApplicationContext(), "No location provider found!", Toast.LENGTH_SHORT).show();
        return;
    }
    lm.addTestProvider(mocLocationProvider, false, false,
            false, …
Run Code Online (Sandbox Code Playgroud)

java gps android android-studio

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

如何在文件中打印一位而不是字节?

我正在使用霍夫曼算法开发文件压缩器,现在我面临的问题是:

通过使用该算法:stackoverflow,我得到以下结果:

a,c,e,f,k,l,r,s,t,v,w = 1 time repeated
o = 2 times repeated

a,c,e,f,k,l,r,s,t,v,w = 7.69231%
and
o = 15.3846%
Run Code Online (Sandbox Code Playgroud)

所以我开始插入二进制树,这将得到结果:

o=00
a=010
e=0110
c=0111
t=1000
s=1001
w=1010
v=1011
k=1100
f=1101
r=1110
l=1111
Run Code Online (Sandbox Code Playgroud)

这意味着树中角色的路径,考虑0为左,1为右.

然后单词"stackoverflow"将是:100110000100111010011111000010110110111011011111001010

好吧,我想将整个值放入一个二进制文件中,这将导致47位,这将是6字节,但我只能使它成为47字节,因为最小值将被放入一个文件与fwrite或者fprintf是1byte,使用sizeof(某事物).

比我的问题是:我如何只在我的文件中打印一下?

c++ file huffman-code

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

在导航上发送道具 goBack

基本上我有三个屏幕,第一个是堆栈导航器:

const stackNav = createStackNavigator({
    Main: {
        screen: MainScreen,
        navigationOptions:({navigation}) => ({
            header: null,
        })
    },
    Detail: {
        screen: DetailScreen,
        navigationOptions: (props) => ({
            title: "Detail",
        })
    }
})
Run Code Online (Sandbox Code Playgroud)

第二个我有一个按钮可以转到详细信息屏幕:

<TouchableOpacity onPress={() => this.props.navigation.navigate("Detail", {name: l.name, subtitle: l.subtitle})}>
Run Code Online (Sandbox Code Playgroud)

最后一个只是信息,我想单击一个按钮并执行: this.props.navigation.goBack(),但是将道具发送到第二个屏幕(MainScreen),一个 setState 和一个整数 id,我该怎么做?

-- 用参数编辑--

我在 MainScreen 中有这个功能:

handleOrdem(texto) {
    console.log('texto: '+texto)
    this.setState({
        param: global.ordemAtiva,
        ordemAtiva: !this.state.ordemAtiva
    });
}
//The onPress code:
onPress={() => this.props.navigation.navigate("Detail", {name: l.name, subtitle: l.subtitle, ordemFunc: () => this.handleOrdem()})}>
Run Code Online (Sandbox Code Playgroud)

这就是我在 Detail.screen 中的称呼:

execBack(param){ …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

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

如何将Java中字符串上的所有"x"替换为数字

我目前无法将字符串中出现的所有"x"替换为数字.

我已经尝试过: myString .replace('x',Integer.toString(i))和类似"x"的东西,而不是整数字符串,替换引号中的数字,它不起作用,字符串保持不变.

然后我做了以下功能:

public static void trocaXporDouble(String a, double c){
            int i;
            for(i=0;i<a.length();i++){
                if(a.charAt(i)=='x'){
                    String newStr1 = a.substring(0,i-1);
                    String newStr = a.substring(i+1,a.length());
                    newStr1.concat(Double.toString(c));
                    newStr1.concat(newStr);
                }
            }
}
Run Code Online (Sandbox Code Playgroud)

但即使有这个功能,它仍然无法正常工作,有人可以帮我一把吗?

提前致谢.

java regex

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

Java中的新功能获得NullPointerException

我宣布:

Discursiva[] questoesDiscursivas = new Discursiva[10];
Run Code Online (Sandbox Code Playgroud)

这是:

public class Discursiva extends Questao{
    private String criteriosCorrecao;
}
Run Code Online (Sandbox Code Playgroud)

而Questao是:

public class Questao {
    private String pergunta;
    private double peso;
}
Run Code Online (Sandbox Code Playgroud)

所以我做了:

str = JOptionPane.showInputDialog("Pergunta da Questao:");
questoesObjetivas[i].setPergunta(str);
Run Code Online (Sandbox Code Playgroud)

并得到了java.lang.NullPointerException.

我在oracle docs中读过:当一个应用程序试图在需要对象的情况下使用null时抛出.这些包括:

Calling the instance method of a null object. 
Accessing or modifying the field of a null object. 
Taking the length of null as if it were an array. 
Accessing or modifying the slots of null as if it were an array. 
Throwing …
Run Code Online (Sandbox Code Playgroud)

java nullpointerexception

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

递归算法的代码逻辑错误

我有一个A*算法的结构,它由以下定义:

typedef struct matriz{
    int g,h,f;
    bool isBarrier, isStart, isEnd;
}matrix;
Run Code Online (Sandbox Code Playgroud)

我已经用这个结构制作了一个矩阵,并将所有初始值设为0.

matrix n[8][8];
Run Code Online (Sandbox Code Playgroud)

然后我做了一个算法来计算起始位置到当前位置之间的距离.

为此我使用了递归方法,因为步骤将是到达该位置所需的步骤数量,每次计算另一个位置时它将增加:

bool checkbounds(int x, int y){
    if(x>=0 && x<=totalsize-1){
        if(y>=0 && y<=totalsize-1) return true;
    }
    return false;
}

bool isGNull(int x, int y){
    if(n[x][y].g==0)return true;
    return false;
}

void countg(int x, int y, int steps){
    if(checkbounds(x-1,y)){
        if(isGNull(x-1,y)){
            n[x-1][y].g=steps;
            countg(x-1,y,steps+1);
        }
    }
    if(checkbounds(x,y-1)){
        if(isGNull(x,y-1)){
            n[x][y-1].g=steps;
            countg(x,y-1,steps+1);
        }
    }
    if(checkbounds(x+1,y)){
        if(isGNull(x+1,y)){
            n[x+1][y].g=steps;
            countg(x+1,y,steps+1);
        }
    }
    if(checkbounds(x,y+1)){
        if(isGNull(x,y+1)){
            n[x][y+1].g=steps;
            countg(x,y+1,steps+1);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是它应该在返回递归时返回初始步骤值.

预期的结果应该是这样的:

| 5  4 …
Run Code Online (Sandbox Code Playgroud)

c++ recursion a-star

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

如何获得0~600的随机值,间隔为10?

我有一个600x600的屏幕,我想基本划分它每10个方格,所以我可以做一个蛇游戏,所以我需要生成这些分区的食物.

我想到的代码:

x.nextInt(10)*x.nextInt(6)*x.nextInt(10)
Run Code Online (Sandbox Code Playgroud)

这不起作用,即使它工作有多个值可以达到20,比如说1*2*10,2*1*10 ......

所以我也想到了这个:

(int)(x.nextInt(600)/10)*10
Run Code Online (Sandbox Code Playgroud)

但它没有使间隔10 ...

我也想到了这个:

Integer.parseInt(Double.toString(x.nextInt(600)/10))*10
Run Code Online (Sandbox Code Playgroud)

但它几乎是愚蠢的,它不起作用(给出一个错误)

如果你不理解我想要的,这里是结果:随机对(x和y):10,60 420,170 550,480 80,600

这是我不想要的:14,52 88,19,551,529 415,550

如何管理逻辑以使此间隔随机化?

java random

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

如何从 React Native Navigator 中删除标题?

我有一个标签栏导航器(水平滑动)并设置在屏幕底部,我想让栏只有图标,没有标题,这是当前的设计:

在此处输入图片说明

这是代码:

const AppTabNavigator = createMaterialTopTabNavigator({
    Home: {
        screen: HomeScreen,
        navigationOptions: {
            tabBarLabel: 'Home',
            tabBarIcon: ({ tintColor }) => (
                <Icon name="ios-home" style={{color: 'white'}} color={tintColor} size={24} />
            )
        }
    },
    Hot: {
        screen: SettingsScreen,
        navigationOptions: {
            tabBarLabel: 'Hot',
            tabBarIcon: ({ tintColor }) => (
                <Icon name="ios-flame" style={{color: 'white'}} color={tintColor} size={24} />
            )
        }
    }
}, {
        order: ['Home', 'Hot'],
        tabBarPosition: 'bottom',
        swipeEnabled: true,
        animationEnabled: true,
        tabBarOptions: {
            activeTintColor: 'orange',
            inactiveTintColor: 'grey',
            style: {
                backgroundColor: '#4050B5',
                borderTopWidth: 0.5,
                borderTopColor: 'grey'
            }, …
Run Code Online (Sandbox Code Playgroud)

node.js react-native

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

如何通过最大量的Tic Tac Toe可能性?

我想知道有多少量的Tic Tac Toes可能性,所以我在网上搜索并找到了一个数学定理,它说Tic Tac Toe 有255168种可能的游戏.

网站:http://www.se16.info/hgb/tictactoe.htm

所以我想知道,我可以创建一个程序,看看计算机能够通过各种可能性来完成这些任务,然后我制作了这段代码:

#include <iostream>
#include <time.h>
#include <windows.h>
#include <stdio.h>
using namespace std;

typedef int TTTField[9];

bool checkIfWon(TTTField j){
    if(j[0]==1&&j[1]==1&&j[2]==1) return true;
    if(j[0]==2&&j[1]==2&&j[2]==2) return true;
    if(j[3]==1&&j[4]==1&&j[5]==1) return true;
    if(j[3]==2&&j[4]==2&&j[5]==2) return true;
    if(j[6]==1&&j[7]==1&&j[8]==1) return true;
    if(j[6]==2&&j[7]==2&&j[8]==2) return true;
    if(j[0]==1&&j[3]==1&&j[6]==1) return true;
    if(j[0]==2&&j[3]==2&&j[6]==2) return true;
    if(j[1]==1&&j[4]==1&&j[7]==1) return true;
    if(j[1]==2&&j[4]==2&&j[7]==2) return true;
    if(j[2]==1&&j[5]==1&&j[8]==1) return true;
    if(j[2]==2&&j[5]==2&&j[8]==2) return true;
    if(j[0]==1&&j[4]==1&&j[8]==1) return true;
    if(j[0]==2&&j[4]==2&&j[8]==2) return true;
    if(j[2]==1&&j[4]==1&&j[6]==1) return true;
    if(j[2]==2&&j[4]==2&&j[6]==2) return true;
    return false; …
Run Code Online (Sandbox Code Playgroud)

c++

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

如何从内存地址获取值?

我想从一个内存地址获取值,而不会崩溃程序.

这是我的代码:

int main(){
    int *ptr=(int*)0x09D37570;
    while(1){
        system("cls");
        cout<<(*ptr);
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是这会导致程序崩溃,它会通过调用*ptr来崩溃,为什么会这样?如何才能毫无问题地获得价值?

c++ memory windows

-3
推荐指数
1
解决办法
4035
查看次数