私はそれに1つと3つのクラスをFragmentActivity
持っています。ボタン 1 をクリックすると、 、 を表示および非表示にしたい。と がクリックされた場合、 を表示および非表示にしたい、またはその逆。私のコードは機能しませんでした。Buttons
Fragment
FragmentOne
FragmentTwo
FragmentThree
Button2
FragmentTwo
FragmentOne
FragmentThree
private void fManager() {
FragmentManager manager = getSupportFragmentManager();
f1 = manager.findFragmentById(R.id.first);
f2 = manager.findFragmentById(R.id.second);
f2 = manager.findFragmentById(R.id.third);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
if (b1.isPressed()) {
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.hide(f2);
transaction.hide(f3);
transaction.show(f1);
transaction.commit();
}
break;
case R.id.button2:
if (b2.isPressed()) {
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.hide(f1);
transaction.hide(f3);
transaction.show(f2);
transaction.commit();
}
break;
case R.id.button3:
if (b3.isPressed()) {
FragmentTransaction transaction = getSupportFragmentManager()
.beginTransaction();
transaction.hide(f1);
transaction.hide(f2);
transaction.show(f3);
transaction.commit();
}
break;
}
}