0

我将我的方法定义如下,并希望返回一个二维数组,但它返回一个 NULL 。有人可以告诉我这有什么问题吗?

public String[][] parseInput150(String[] inputPercent150, String[][] input150Parsed ) {

    String inputPer150fromXML = getResources().getString(R.string.InputPercent150);

    inputPercent150 = inputPer150fromXML.split(Pattern.quote("|"));
    input150Parsed = new String[inputPercent150.length-1][];
    for (int i = 1; i < inputPercent150.length; i++) {
        input150Parsed[i-1] = inputPercent150[i].split(Pattern.quote(" "));
    } 
    for (int i = 0; i < input150Parsed.length; i++){

            Log.e("TAG","Parsed Array value = " + Arrays.toString(input150Parsed[i]));

    }

    return input150Parsed;      
}

方法调用如下:

@Override
  public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);        
       setContentView(R.layout.activity_main);        
    operationalSoldiers = (EditText) findViewById(R.id.operationalSoldiers);
    operationalSoldiers.setText("150");        
    initialInput = setinitialInput(initialInput);
    input150Parsed = parseInput150(inputPercent150, input150Parsed);                        
    listView = (ListView) findViewById(R.id.list);
    selectAll = (Button) findViewById(R.id.selectAll);
    deselectAll = (Button) findViewById(R.id.deselectAll);        
    ArrayAdapter<String> adapter;
    array =  getResources().getStringArray(R.array.facilities);
    strings1 = new ArrayList(Arrays.asList(array));                
    TopicSelectionListAdapter topicSelectionListAdapter = new TopicSelectionListAdapter(
            second.this, R.layout.listrow, strings1);
    listView.setAdapter(topicSelectionListAdapter);
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    for(int i=0;i<strings1.size();i++){
        listView.setItemChecked(i, false);
      }
       listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position,
                long arg3) {
            CheckedTextView selectedItem = (CheckedTextView) view;
            boolean isChecked = selectedItem.isChecked();
           Log.e("TAG","item clicked position = " + position + " isChecked = " + isChecked);
            for(int i=0; i< strings1.size(); i++){
                if(!isChecked){
                    bArray[i]= 1;
                }
                else{
                    bArray[i]= 0;
                }
                    System.out.print(bArray[i]);
            }Log.e("TAG","boolean Array value = " + bArray);
          }
    });
    selectAll.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        @Override
        public void onClick(View v) {
            for(int i=0;i<strings1.size();i++){
                listView.setItemChecked(i, true);
                bArray[i]= 1;
            }
            totalSoldiers = (int) (operationalSoldiers.getAlpha() + (operationalSoldiers.getAlpha() * 0.13));
            for (int r=0; r < input150Parsed.length; r++ ){
                for(int c=0; c < input150Parsed[r].length; c++){                        
                    calculatedParValues[r][c] = ((totalSoldiers * (Integer.valueOf(input150Parsed[r][c]))) * Integer.valueOf(initialInput[c]));
                }
            }
          for (int i = 0; i < calculatedParValues.length; i++){
        Log.e("TAG","Parsed parameter value = " + Arrays.toString(calculatedParValues[i]));
        }
          }
    });
4

0 回答 0