Код: Выделить всё
public class MainActivity extends AppCompatActivity implements
SshFragment.SshTaskListener {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setup/handle retained SshFragment
final String SSH_FRAGMENT_TAG = "SSH_FRAGMENT";
if (savedInstanceState == null) {
// The Activity is NOT being re-created so we can instantiate a new Fragment
// and add it to the Activity
sshFragment = new SshFragment();
getSupportFragmentManager()
.beginTransaction()
// It's almost always a good idea to use .replace instead of .add so that
// you never accidentally layer multiple Fragments on top of each other
// unless of course that's your intention
.replace(R.id.ssh_fragment, sshFragment, SSH_FRAGMENT_TAG)
.commit();
} else {
// The Activity IS being re-created so we don't need to instantiate the Fragment or add it,
// but if we need a reference to it, we can use the tag we passed to .replace
sshFragment = (SshFragment) getSupportFragmentManager().findFragmentByTag(SSH_FRAGMENT_TAG);
}
Код: Выделить всё
FATAL EXCEPTION: main
Process: com.example.atest, PID: 11547
java.lang.IllegalArgumentException: No view found for id 0x7f0801f2 (com.example.atest:id/ssh_fragment) for fragment SshFragment{370be34} (d598c437-ff65-47ea-88a9-e764647d34f9 id=0x7f0801f2 tag=SSH_FRAGMENT)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:513)
Код: Выделить всё
Нужно ли мне еще иметь..
Код: Выделить всё
@Override
public View onCreateView(){}
Подробнее здесь: https://stackoverflow.com/questions/784 ... inactivity
Мобильная версия