Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未调用Android函数_Java_Android_Function - Fatal编程技术网

Java 未调用Android函数

Java 未调用Android函数,java,android,function,Java,Android,Function,我的片段中的这个函数正在被另一个函数调用,该函数在单击按钮时被调用getGridVals()在开始时在mycalculate()函数中被调用,但在Log中从getGridVals()输出的内容与应该的一样。 只有Log.v(“test”、“HI”)被输出 但是,在我的calculate()函数中,会输出Log值 public void calculate(){ int[][] pegs = new int[3][3]; getGridVals();// this is not

我的片段中的这个函数正在被另一个函数调用,该函数在单击按钮时被调用
getGridVals()
在开始时在my
calculate()
函数中被调用,但在
Log
中从
getGridVals()
输出的内容与应该的一样。
只有
Log.v(“test”、“HI”)被输出
但是,在我的
calculate()
函数中,会输出
Log

public void calculate(){ 
    int[][] pegs = new int[3][3];
    getGridVals();// this is not working

////////This loop isnt working either for some reason, its just not even outputting anything
    for(int i=1;i<9;i++)
        Log.e("etC", etCollectionB[i]);

    int k=0;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
        {
            if(etCollectionB[k].equals(""))
                pegs[i][j] = 0;
            else
                pegs[i][j] = Integer.valueOf(etCollectionB[k]);
            Log.e("Value", String.valueOf(pegs[i][j]));
            k++;
        }

}
public void calculate(){
int[]pegs=新int[3][3];
getGridVals();//这不起作用
////////由于某种原因,这个循环也不起作用,它甚至不输出任何东西

对于(inti=1;i噢,哇,我发现了。这是一个愚蠢的错误。因为没有从
tentext1.getText().toString()检索任何内容,
因此日志甚至没有出现,因为没有任何输出。谢谢大家。

首先,它返回布尔值,因此调用函数的正确方法应该是:Boolean b=getGridVals();第二,这些函数/方法是否属于同一个类?请检查我的编辑,以正确的方式调用该函数。是否尝试清理和重建?@DmitryKvochkin是否分配返回值没有任何区别。@DmitryKvochkin我尝试过,但效果并不好笑——我想到了这一点,但您曾经编写过那
String.valueOf(9)
也没有在日志中打印任何内容。不过,很高兴你找到了它!:)是的,对不起,我以为我没有看到
String.valueOf(9)
但那是因为我没有一直向下滚动。我在执行
log.v(“test”、“+testext1.getText().toString()之后找到了它。);
它只打印出“.”
 public boolean getGridVals(){



        for(int i=1;i<9;i++)
        {
            EditText tempText1 = new EditText(mContext);
            tempText1.setText((CharSequence) mGrid.getItemAtPosition(i));
                    //this doesn't output
            Log.v("temp text ", tempText1.getText().toString());
                    //this outputs 
                    Log.v("test", "HI");



        }

        //this too doesnt output
        Log.d("et collection 1", String.valueOf(etCollectionB[1]));
        for(int i=0;i<9;i++)
        {
            etCollectionB[i] = (String) mGrid.getItemAtPosition(i);
            Log.e("etCollectionB", etCollectionB[i]);


        }
            return true;
        //return false;
        //return etCollectionB;
    }