1b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell/*
2b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * Copyright (C) 2017 The Android Open Source Project
3b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell *
4b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * Licensed under the Apache License, Version 2.0 (the "License");
5b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * you may not use this file except in compliance with the License.
6b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * You may obtain a copy of the License at
7b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell *
8b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell *      http://www.apache.org/licenses/LICENSE-2.0
9b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell *
10b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * Unless required by applicable law or agreed to in writing, software
11b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * distributed under the License is distributed on an "AS IS" BASIS,
12b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * See the License for the specific language governing permissions and
14b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * limitations under the License.
15b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell */
16b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
171503d52153986fdcfe7e744795010708b7410892Ian Lakepackage androidx.navigation.testapp;
18b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
19b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.os.Bundle;
2051c1fe23339181415ed6837f64218b29f677cd59Ian Lakeimport android.support.annotation.NonNull;
21b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.support.annotation.Nullable;
22b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.support.v4.app.Fragment;
23b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.view.LayoutInflater;
24b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.view.View;
25b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.view.ViewGroup;
26b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.widget.Button;
27b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellimport android.widget.TextView;
28b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
291503d52153986fdcfe7e744795010708b7410892Ian Lakeimport androidx.navigation.Navigation;
301503d52153986fdcfe7e744795010708b7410892Ian Lake
31b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell/**
32b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell * Fragment used to show how to navigate to another destination
33b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell */
34b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powellpublic class MainFragment extends Fragment {
35b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    @Override
36b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    public void onCreate(@Nullable Bundle savedInstanceState) {
37b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell        super.onCreate(savedInstanceState);
38b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    }
39b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
40b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    @Nullable
41b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    @Override
4251c1fe23339181415ed6837f64218b29f677cd59Ian Lake    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
43b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell                             @Nullable Bundle savedInstanceState) {
44b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell        return inflater.inflate(R.layout.main_fragment, container, false);
45b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    }
46b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
47b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    @Override
4851c1fe23339181415ed6837f64218b29f677cd59Ian Lake    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
49b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell        super.onViewCreated(view, savedInstanceState);
5051c1fe23339181415ed6837f64218b29f677cd59Ian Lake        TextView tv = view.findViewById(R.id.text);
51b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell        tv.setText(getArguments().getString("myarg"));
52b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell
5351c1fe23339181415ed6837f64218b29f677cd59Ian Lake        Button b = view.findViewById(R.id.next_button);
54b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell        b.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.next));
55b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell    }
56b15ee75fa904cd1045caa68d5482a76d0cc14f33Adam Powell}
57