Example usage for android.view LayoutInflater inflate

List of usage examples for android.view LayoutInflater inflate

Introduction

In this page you can find the example usage for android.view LayoutInflater inflate.

Prototype

public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot) 

Source Link

Document

Inflate a new view hierarchy from the specified XML node.

Usage

From source file:com.facebook.android.friendsmash.ScoreboardFragment.java

@TargetApi(13)
@Override/*from  w  w  w. j  a va  2 s  .  c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_scoreboard, parent, false);

    scoreboardContainer = (LinearLayout) v.findViewById(R.id.scoreboardContainer);
    progressContainer = (FrameLayout) v.findViewById(R.id.progressContainer);

    // Set the progressContainer as invisible by default
    progressContainer.setVisibility(View.INVISIBLE);

    // Note: Scoreboard is populated during onResume below

    return v;
}

From source file:com.mohammedsazidalrashid.android.sunshine.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_forecast, container, false);

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.light_blue_500, R.color.orange_500, R.color.teal500,
            R.color.green_500);//from ww w  . ja va 2s  .c om

    mForecastAdapater = new ArrayAdapter<>(getActivity(), R.layout.list_item_forecast,
            R.id.list_item_forecast_textview, new ArrayList<String>());

    final ListView listviewForecast = (ListView) rootView.findViewById(R.id.listview_forecast);
    listviewForecast.setAdapter(mForecastAdapater);

    listviewForecast.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            String forecast = mForecastAdapater.getItem(position);
            MainActivity.bundleForFragments.putString(EXTRA_FORECAST, forecast);
            getActivity().getFragmentManager().beginTransaction().addToBackStack(null)
                    .setCustomAnimations(R.animator.enter_anim, R.animator.exit_anim,
                            R.animator.enter_anim_reverse, R.animator.exit_anim_reverse)
                    .replace(R.id.container, new DetailsFragment()).commit();
        }
    });

    listviewForecast.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {

        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int topRowVerticalPosition = (listviewForecast == null || listviewForecast.getChildCount() == 0) ? 0
                    : listviewForecast.getChildAt(0).getTop();
            mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
        }
    });

    return rootView;
}

From source file:com.microsoft.office365.msgraphsnippetapp.SnippetDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_snippet_detail, container, false);
    ButterKnife.inject(this, rootView);
    mSnippetDescription.setText(mItem.getDescription());
    return rootView;
}

From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_browser, container, false);

    initList(inflater, rootView);/*from  w  ww  .  ja v  a2  s .  co m*/
    return rootView;
}

From source file:net.eledge.android.europeana.search.model.record.enums.RecordDetails.java

View drawDetailView(int titleResId, String value, ViewGroup parent, LayoutInflater inflater) {
    View view = inflater.inflate(R.layout.listitem_record_detail, parent, false);
    TextView textTitle = (TextView) view.findViewById(android.R.id.text1);
    TextView textValue = (TextView) view.findViewById(android.R.id.text2);
    textTitle.setText(titleResId);/*from  w w w . j a v  a2 s . c o m*/
    textValue.setText(value);
    return view;
}

From source file:com.ymt.demo1.plates.hub.MyHubFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview_ultra_list_view, container, false);

    scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        scrollView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }// ww  w  .j  a v a2 s  .  c  o m
    }

    initView(view);
    switch (type) {
    case MY_POST: //?
        postList = new ArrayList<>();
        mQueue.add(getHubMyPost(AppContext.now_user_name, index));
        pullToRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
        break;
    case MY_REPLIES: //
        replyList = new ArrayList<>();
        mQueue.add(getHubMyReplies(AppContext.now_user_name, index));
        pullToRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
        break;
    case MY_SYS_INFO: //?
        sysInfoList = new ArrayList<>();
        mQueue.add(getHubSysInfo(AppContext.now_user_name));
        pullToRefreshListView.setMode(PullToRefreshBase.Mode.DISABLED);
        break;
    default:
        break;
    }

    return view;
}

From source file:in.codehex.facilis.AllDealsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_all_deals, container, false);

    initObjects(view);/*from w  w w . j  a  va2  s .  co  m*/
    prepareObjects();

    return view;
}

From source file:in.codehex.facilis.HotDealsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_hot_deals, container, false);

    initObjects(view);/*from w w  w. j  a v  a2 s . co  m*/
    prepareObjects();

    return view;
}

From source file:de.sourcestream.movieDB.controller.GenresList.java

/**
 * Called to have the fragment instantiate its user interface view.
 *
 * @param inflater           sets the layout for the current view.
 * @param container          the container which holds the current view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed from a previous saved state as given here.
 *                           Return the View for the fragment's UI, or null.
 *//*  ww  w .  j  a  va  2s . co m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    rootView = inflater.inflate(R.layout.genreslist, container, false);
    activity = ((MainActivity) getActivity());
    spinner = (ProgressBar) rootView.findViewById(R.id.progressBar);
    listView = (AbsListView) rootView.findViewById(R.id.genresList);

    Tracker t = ((MovieDB) activity.getApplication()).getTracker();
    t.setScreenName("Genres");
    t.send(new HitBuilders.ScreenViewBuilder().build());

    return rootView;
}

From source file:es.uniovi.imovil.fcrtrainer.TwosComplementExerciseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView;/*from  ww  w.ja v  a 2 s . co m*/
    rootView = inflater.inflate(R.layout.fragment_twos_complement, container, false);

    rel_cards = (RelativeLayout) rootView.findViewById(R.id.rel_cards);
    but_check = (Button) rootView.findViewById(R.id.bCheck);
    but_solution = (Button) rootView.findViewById(R.id.bSeesolution);
    but_setMode = (Button) rootView.findViewById(R.id.bSetconversion);
    edi_answer = (EditText) rootView.findViewById(R.id.etAnswer);
    tex_tittle = (TextView) rootView.findViewById(R.id.txTittle);
    tex_numberToConvert = (TextView) rootView.findViewById(R.id.txNumbertoconvert);

    but_check.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (GameMode == false) {
                if (but_check.getText().equals(getResources().getString((R.string.next_numb)))) {
                    edi_answer.setText("");
                    but_check.setText(getResources().getString(R.string.check));
                    generateRand(modeToDecimal);
                } else {
                    checkAnswer();
                }
            } else {
                checkAnswer();
            }
        }
    });

    but_solution.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            seeSolution();
        }
    });

    but_setMode.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            modeToDecimal = !modeToDecimal;
            generateRand(modeToDecimal);
            edi_answer.setText("");
        }
    });

    Log.i(getClass().getSimpleName(), "onViewCreated");

    if (savedInstanceState != null) {
        Log.i(getClass().getSimpleName(), "Inside savedInstanceState");
        modeToDecimal = savedInstanceState.getBoolean("modeToDecimal");
        numbToConvert = savedInstanceState.getString("numbToConvert");

        updateUI();
    } else
        generateRand(modeToDecimal);

    return rootView;
}