错误获取字符串到数组字符串& string to array int

时间:2016-02-28 23:49:01

标签: android arrays string android-edittext int

我试图在编辑文本中编写类似1 + 1的内容,方法是按下app按钮并将整数转换为字符串,以便将它们放在exger的其余部分旁边:11不是1 + 1(= 2 )我得到错误"致命异常"用这行代码 当按任意数字按钮时

N [ii] = Integer.parseInt(stringNumber);

也是错误"致命异常"在displayCalculations方法中按下Sins x,+, - 按钮

private void insertOrCheckNumber() {
    if (End == 0) {
        ii++;
    } else if (u == 0) {
        N = new int[ii];
        stringNumber = stringNumber + String.valueOf(num);
        displayCalculations(stringNumber);
        N[ii] = Integer.parseInt(stringNumber);
    }
    if (u == 1) {
        Sins = new String[iii];
        displayCalculations(Sins[iii]);
    }

}
private void clickNumber(int cN) {
    u = 0;
    num = cN;
    insertOrCheckNumber();
}

private void displayCalculations(String txt) {
    Calcs = String.valueOf(showCalcs.getText());
    showCalcs.setText(Calcs + " " + txt);
}

1 个答案:

答案 0 :(得分:1)

在您的活动中

私人ListView列表视图;

<强>的onCreate

listView = (ListView) findViewById(R.id.listView);  
ArrayList<> finalN = new ArrayList<y>;
customAdapter = new listAdapter(this,R.layout.listview_example, finalN);
        listView.setAdapter(customAdapter);

public class listAdapter extends ArrayAdapter<>
        {
            public listAdapter(Context context, int resource, List<> objects) {
            super(context, resource, objects);
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
            Display display = wm.getDefaultDisplay();
            Point size = new Point();

            View v = convertView;
            if (v == null) {
                LayoutInflater vi;
                vi = LayoutInflater.from(getContext());
                v = vi.inflate(R.layout.listview_example, null);
            }
               //Setting the value to the textfields
            return v;
        }

如果您需要我的完整代码,请询问并发送;)