0

I have made a form and connected it to a firebase database. It has an EditText in which you write something(e.x a suggestion) and then you press the button to submit it in the firebase database. But how can I refresh the whole xml file so I can write a new suggestion. I have tried this at first

setContentView(R.layout.activity_suggestions);

But after that, the xml file was refreshed but I couldn't submit a new suggestion. and then I tried this which works but its really annoying because if I press the back button it gets me back to the same page

Intent reportBugIntent = new Intent(ReportBug.this, ReportBug.class);
                startActivity(reportBugIntent);

Is the any other way I can do that?

2 Answers2

2

You just need to clear editText content on submit button click.

submitButton.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View view) {
            // Save content to firebase database
            // clear the editext
            editText.setText("");// where edit text is your suggestion edit text
       }
}
Krishna Sharma
  • 2,828
  • 1
  • 12
  • 23
0

There are! How about refreshing Activity: Reload activity in Android

The current code is useless because it will just return you to the current page, instead, you may wanna finish the current Activity by finish() method then doing such thing.

So:

finish();
startActivity(getIntent());

Or:

// Refresh main activity upon close of dialog box
Intent refresh = new Intent(this, clsMainUIActivity.class);
startActivity(refresh);
this.finish(); //

As mentioned on the above link.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • Glad to hear it's working. Anyways, you could make the `EditText` text to zero -> "" like the other user mentioned but as you wish. – ʍѳђઽ૯ท Aug 18 '18 at 08:35
  • this is short and efficient: finish(); startActivity(getIntent()); By the way which one is the snappiest one? –  Aug 18 '18 at 08:44
  • The other answer by Krishna Sharma. `yourEditText.setText("");`. It also depends on what you are doing on the `Activity`. Just wanted you to take a look. Fair enough then. – ʍѳђઽ૯ท Aug 18 '18 at 09:04