R
R
RusSanta2017-03-23 00:24:05
Java
RusSanta, 2017-03-23 00:24:05

When flipping the screen, two EditTexts appear, one overlaps the other, how to fix it?

I wrote a calculator, I used EditText for the number output field, the problem is that when I turn the screen, it looks like I have two EditTexts, as a result, the values ​​\u200b\u200bare added to one, and the other is default, and it interferes09390422e5324ef4892ce0eb7b6248bf.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SofroN, 2017-03-23
@RusSanta

The problem is most likely in how you show the fragment.
You need to check if the fragment is already added, if added, either replace or show

// показываем нужный фрагмент
    private void showFragment(Fragment fragment) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        if (fm.findFragmentByTag(TAG) == null) {
            transaction.add(R.id.activity_content, fragment, TAG);
        } else if (fragment.getClass().equals(fm.findFragmentByTag(TAG).getClass())){
            transaction.show(fragment);
        } else {
            transaction.replace(R.id.activity_content, fragment, TAG);
        }
        //transaction.addToBackStack(fragment.getClass().getName());
        transaction.commit();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question