1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.example.android.supportv4.widget;
17 
18 import android.os.Bundle;
19 import android.view.LayoutInflater;
20 import android.view.View;
21 import android.view.ViewGroup;
22 import android.widget.LinearLayout;
23 import android.widget.TextView;
24 
25 import androidx.fragment.app.Fragment;
26 
27 import com.example.android.supportv4.R;
28 
29 import org.jspecify.annotations.NonNull;
30 import org.jspecify.annotations.Nullable;
31 
32 /**
33  * Simple LinearLayout with ~50 TextViews.
34  */
35 public class PreferenceScreenDetailsTemplateFragment extends Fragment {
36 
37     @Override
onCreateView( @onNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState )38     public @NonNull View onCreateView(
39             @NonNull LayoutInflater inflater,
40             @Nullable ViewGroup container,
41             @Nullable Bundle savedInstanceState
42     ) {
43         View view =  inflater.inflate(
44                 R.layout.fragment_preference_screen_details_template,
45                 container,
46                 false
47         );
48 
49         LinearLayout linearLayout = view.findViewById(R.id.linear_layout);
50 
51         for (int index = 1; index <= 50; index++) {
52             TextView textView = new TextView(getContext());
53             textView.setText("TextView " + index);
54             textView.setFocusable(true);
55             textView.setFocusableInTouchMode(true); // For keyboard/touch based focus
56             textView.setPadding(16, 16, 16, 16);
57 
58             linearLayout.addView(textView);
59         }
60         return view;
61     }
62 }
63