0

Here is the view flipper xml

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/first"  layout="@layout/simp2" />
<include android:id="@+id/second"  layout="@layout/simp2adv" />
</ViewFlipper>

simp2.xml and simp2adv.xml both have a textview. How do I ensure that they both show the same content? I tried giving both textview the same id, but only one gets edited. The other is ignored.

antoniom
  • 3,143
  • 1
  • 37
  • 53
Evans Kakpovi
  • 312
  • 1
  • 5
  • 12

1 Answers1

0

I solved it by making switch statements in my activity class. for example:

switch (flipper.getDisplayedChild()) {
    case 0:
        focusEquationBox(R.id.equation2);
        var.dataBox.setText("");
        break;
    case 1:
        focusEquationBox(R.id.equation3);
        var.dataBox.setText("");
        break;
    case 2:
        focusEquationBox(R.id.equation4);
        var.dataBox.setText("");
        break;
    case 3:
        focusEquationBox(R.id.equation);
        var.dataBox.setText("");
        break;
    }

with

void focusEquationBox(int id) {
    var.dataBox = (EditText) findViewById(id);
}

Doing so allows me to modify only the visible textView. When I flip the view, i save the content of the visible textView to a String variable, then load in into the next visible textView.

Evans Kakpovi
  • 312
  • 1
  • 5
  • 12