A
A
Anton Peat2014-11-25 18:37:49
Java
Anton Peat, 2014-11-25 18:37:49

How to solve problem with deleting substring from file in JAVA?

In OnCreate

Update("studentsapp1pn.txt",(RadioGroup) findViewById(R.id.rasRgPn));

public void Update(String filename,RadioGroup rclv)
    {
        String TEXT="";

        try {
            // открываем поток для чтения
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    openFileInput(filename)));
            String str = "";
            // читаем содержимое
            while ((str = br.readLine()) != null) {final RadioButton newRadioButton = new RadioButton(this);
                newRadioButton.setText(str.toString());
                newRadioButton.setId(200+NumItems);
                newRadioButton.setButtonDrawable(null);
                rclv.addView(newRadioButton);
                NumItems++;

                newRadioButton.setOnLongClickListener(new View.OnLongClickListener() {
                    public boolean onLongClick(View view) {
                        newRadioButton.setVisibility(View.GONE);
                        return false;
                    }
                });
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }




    }

1) Somewhere in the Update function an error occurs. The emulator takes a long time to load.. I'll watch debug again... It won't really help me, => I'll post it for you...
2) Is there a more rational solution?
I'm in Android Studio, java.
2a100d89332246c7bb8bef4bc00f23e6.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2014-11-25
@onepavel

rclv is null, looks like "(RadioGroup) findViewById(R.id.rasRgPn)" doesn't find the view

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question