1

I am trying to write something like 1 + 1 in the edit text by pressing the app buttons and in converting the intgers to string in order to have them beside the rest of the intger ex: 11 not 1+1 (=2) i am getting error "FATAL EXCEPTION" with this line of code when pressing any number button

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

also error "FATAL EXCEPTION" in displayCalculations methode on pressing on the Sins x,+,- buttons

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 Answer 1

1

In your activity

private ListView 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;
        }

if you want my full code, ask and i'll send it ;)

Sign up to request clarification or add additional context in comments.

2 Comments

thanks but the list works as a string or integer if I used it without the adapter and the list view just as an value ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.