Java Code Examples for android.view.LayoutInflater#inflate()

The following examples show how to use android.view.LayoutInflater#inflate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleAnimateToWithOrientation.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View root = inflater.inflate(R.layout.sample_cachemgr, container,false);

        mMapView = new MapView(getActivity());
        ((LinearLayout) root.findViewById(R.id.mapview)).addView(mMapView);
        btnCache = root.findViewById(R.id.btnCache);
        btnCache.setOnClickListener(this);
        next();

/*        final RotationGestureOverlay rotationGestureOverlay = new RotationGestureOverlay(mMapView);
        rotationGestureOverlay.setEnabled(true);
        mMapView.getOverlays().add(rotationGestureOverlay);
*/
        return root;
    }
 
Example 2
Source File: SpareClassroomsFragment.java    From PKUCourses with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.fragment_spare_classrooms, container, false);
    // 查找xml文件中的对象并保存进Java变量
    mSpareClassroomsSwipeContainer = linearLayout.findViewById(R.id.spare_classrooms_swipe_container);
    mWebView = linearLayout.findViewById(R.id.spare_classrooms_web_view);

    mSpareClassroomsSwipeContainer.setOnRefreshListener(this);
    mSpareClassroomsSwipeContainer.setColorSchemeColors(getResources().getColor(R.color.colorPrimary), getResources().getColor(R.color.colorAccent));

    // 显示Loading的小动画,并在后台读取课程列表
    showLoading(true);
    mLoadingTask = new SpareClassroomsLoadingTask();
    mLoadingTask.execute((Void) null);

    return linearLayout;
}
 
Example 3
Source File: NavigationDrawerFragment.java    From android-sensor-example with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mDrawerListView = (ListView) inflater.inflate(
            R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });

    // populate the fragments available for navigation here
    mDrawerListView.setAdapter(new ArrayAdapter<Fragment>(
            getActionBar().getThemedContext(),
            android.R.layout.simple_list_item_1,
            android.R.id.text1,
            new Fragment[]{
                    new WelcomeFragment(),
                    new ListSensorFragment(),
                    new SensorDataFragment(),
                    new ScheduleServiceFragment()
            }));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return mDrawerListView;
}
 
Example 4
Source File: OptionHotFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_hot_option, container, false);
    initView(view);
    return view;
}
 
Example 5
Source File: VideoTabLayout.java    From Toutiao with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_video_tab, container, false);
    initView(view);
    initData();
    return view;
}
 
Example 6
Source File: SlideFragment.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_slide, container, false);
    titleTextView = (TextView) view.findViewById(R.id.txt_title_slide);
    descriptionTextView = (TextView) view.findViewById(R.id.txt_description_slide);
    imageView = (ImageView) view.findViewById(R.id.image_slide);
    initializeView();
    return view;
}
 
Example 7
Source File: StockPortfolioListFragment.java    From Building-Professional-Android-Applications with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.portfolio_fragment_stock_list, container, false);
    unbinder = ButterKnife.bind(this, view);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(
            new LinearLayoutManager(this.getContext())
    );

    mRecyclerView.setAdapter(mAdapter);


    return view;
}
 
Example 8
Source File: UsersFragment.java    From Capstone-Project with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_users, container, false);
    ButterKnife.bind(this, view);
    return view;
}
 
Example 9
Source File: EarthquakeListFragment.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_earthquake_list,
    container, false);
  mRecyclerView = view.findViewById(R.id.list);
  mSwipeToRefreshView = view.findViewById(R.id.swiperefresh);

  return view;
}
 
Example 10
Source File: AdamantTransferMessageViewHolder.java    From adamant-android with GNU General Public License v3.0 5 votes vote down vote up
public AdamantTransferMessageViewHolder(Router router, Context context, View v, AdamantMarkdownProcessor adamantAddressProcessor, Avatar avatar) {
    super(context, v, adamantAddressProcessor, avatar);
    this.router = router;

    LayoutInflater inflater = LayoutInflater.from(context);
    contentView = inflater.inflate(R.layout.list_subitem_adamant_transfer_message, contentBlock, false);
    contentBlock.addView(contentView);
    amountView = contentView.findViewById(R.id.list_item_message_amount);
}
 
Example 11
Source File: ProjectOverdueTasksFragment.java    From Kandroid with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        Log.d("ProjectsFragment", "onCreateView");
        return inflater.inflate(R.layout.fragment_expandable_list, container, false);
    }
 
Example 12
Source File: RecycleBinFragment.java    From nono-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.recycle_view, container, false);
    return view;
}
 
Example 13
Source File: SplashSettingsFragment.java    From minx with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_splash_settings, container, false);
}
 
Example 14
Source File: CameraConnectionFragment.java    From fritz-examples with MIT License 4 votes vote down vote up
@Override
public View onCreateView(
        final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    return inflater.inflate(layout, container, false);
}
 
Example 15
Source File: VideoViewBinder.java    From Interessant with Apache License 2.0 4 votes vote down vote up
@NonNull @Override
protected Holder onCreateViewHolder(
        @NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
    View view = inflater.inflate(R.layout.item_movie, parent, false);
    return new Holder(view);
}
 
Example 16
Source File: TreeAdapter.java    From TreeView with Apache License 2.0 4 votes vote down vote up
@Override
public TreeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View view = inflater.inflate(R.layout.rv_item_tree, parent, false);
    return new TreeViewHolder(view);
}
 
Example 17
Source File: MultiImagePickerFragment.java    From YImagePicker with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.picker_activity_multipick, container, false);
    return view;
}
 
Example 18
Source File: SelectOneAutoAdvanceWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    LayoutInflater inflater = LayoutInflater.from(getContext());

    mItems = getSelectChoices();
    buttons = new Vector<>();
    listener = (AdvanceToNextListener)context;

    String s = null;
    if (prompt.getAnswerValue() != null) {
        s = ((Selection)prompt.getAnswerValue().getValue()).getValue();
    }

    //Is this safe enough from collisions?
    buttonIdBase = Math.abs(prompt.getIndex().hashCode());

    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {

            RelativeLayout thisParentLayout =
                    (RelativeLayout)inflater.inflate(R.layout.quick_select_layout, null);

            final LinearLayout questionLayout = (LinearLayout)thisParentLayout.getChildAt(0);
            ImageView rightArrow = (ImageView)thisParentLayout.getChildAt(1);

            final RadioButton r = new RadioButton(getContext());
            r.setOnCheckedChangeListener(this);
            String markdownText = prompt.getSelectItemMarkdownText(mItems.get(i));
            if (markdownText != null) {
                r.setText(forceMarkdown(markdownText));
            } else {
                r.setText(prompt.getSelectChoiceText(mItems.get(i)));
            }
            r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontSize);
            r.setId(i + buttonIdBase);
            r.setEnabled(!prompt.isReadOnly());
            r.setFocusable(!prompt.isReadOnly());

            Drawable image = getResources().getDrawable(R.drawable.icon_auto_advance_arrow);
            rightArrow.setImageDrawable(image);
            rightArrow.setOnTouchListener((v, event) -> {
                r.onTouchEvent(event);
                return false;
            });

            buttons.add(r);

            if (mItems.get(i).getValue().equals(s)) {
                r.setChecked(true);
            }

            String audioURI = null;
            audioURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI = null;
            imageURI =
                    prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                            FormEntryCaption.TEXT_FORM_IMAGE);

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = MediaLayout.buildAudioImageVisualLayout(getContext(), r, audioURI, imageURI, videoURI, bigImageURI);

            questionLayout.addView(mediaLayout);

            // Last, add the dividing line (except for the last element)
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            if (i != mItems.size() - 1) {
                mediaLayout.addDivider(divider);
            }

            addView(thisParentLayout);
        }
    }
}
 
Example 19
Source File: PlayerControlFragment.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_player_control, container, false);
    return rootView;
}
 
Example 20
Source File: ImagePickerActivity.java    From titanium-imagepicker with Apache License 2.0 4 votes vote down vote up
@Override
public PhotoHolder onCreateViewHolder(ViewGroup v, int type) {
    LayoutInflater inflater = LayoutInflater.from(TiApplication.getAppRootOrCurrentActivity());
    View view = inflater.inflate(main_image_view, v, false);
    return new PhotoHolder(view);
}