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.achep.acdisplay.acdisplay.components.NotifyWidget.java

@Override
protected ViewGroup onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container,
        @Nullable ViewGroup sceneView) {
    boolean initialize = sceneView == null;
    if (initialize) {
        sceneView = (ViewGroup) inflater.inflate(R.layout.acdisplay_scene_notification, container, false);
        assert sceneView != null;
    }//from  w  w w.j av  a 2s .  c o  m

    mNotifyWidget = (NotificationWidget) sceneView.findViewById(R.id.notification);

    if (!initialize) {
        return sceneView;
    }

    // mNotifyWidget.setActionButtonsAlignment(RelativeLayout.ALIGN_BOTTOM);
    mNotifyWidget.setOnClickListener(new NotificationWidget.OnClickListener() {

        @Override
        public void onClick(NotificationWidget widget, View v) {
            final OpenNotification osbn = widget.getNotification();
            if (osbn != null) {
                getHostFragment().unlock(new Runnable() {
                    @Override
                    public void run() {
                        osbn.click();
                    }
                }, false);
            }
        }

        @Override
        public void onActionButtonClick(NotificationWidget widget, View v, final PendingIntent pendingIntent) {
            getHostFragment().unlock(new Runnable() {
                @Override
                public void run() {
                    PendingIntentUtils.sendPendingIntent(pendingIntent);
                }
            }, false);
        }

    });

    return sceneView;
}

From source file:fr.bde_eseo.eseomega.hintsntips.TipsFragment.java

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

    // UI/*w  w w  .  j ava2  s . c  o  m*/
    View rootView = rootInfl.inflate(R.layout.fragment_tips_list, container, false);
    swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.tips_refresh);
    swipeRefreshLayout.setColorSchemeColors(R.color.md_blue_800);
    progCircle = (ProgressBar) rootView.findViewById(R.id.progressList);
    tv1 = (TextView) rootView.findViewById(R.id.tvListNothing);
    tv2 = (TextView) rootView.findViewById(R.id.tvListNothing2);
    img = (ImageView) rootView.findViewById(R.id.imgNoSponsor);
    progCircle.setVisibility(View.GONE);
    progCircle.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.md_grey_500),
            PorterDuff.Mode.SRC_IN);
    tv1.setVisibility(View.GONE);
    tv2.setVisibility(View.GONE);
    img.setVisibility(View.GONE);
    disabler = new RecyclerViewDisabler();

    // I/O cache data
    cachePath = getActivity().getCacheDir() + "/";
    cacheFileEseo = new File(cachePath + "tips.json");

    // Model / objects
    sponsorItems = new ArrayList<>();
    mAdapter = new MyTipsAdapter(getActivity(), sponsorItems);
    recList = (RecyclerView) rootView.findViewById(R.id.recyList);
    recList.setAdapter(mAdapter);
    recList.setHasFixedSize(false);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    recList.setLayoutManager(llm);
    mAdapter.setSponsorItems(sponsorItems);

    //sponsorItems.add(new SponsorItem("A", "B", "C", "D", "E", null));
    mAdapter.notifyDataSetChanged();

    // Start download of data
    AsyncJSON asyncJSON = new AsyncJSON(true); // circle needed for first call
    asyncJSON.execute(Constants.URL_JSON_SPONSORS);

    // Swipe-to-refresh implementations
    timestamp = 0;
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            //Toast.makeText(getActivity(), "Refreshing ...", Toast.LENGTH_SHORT).show();
            long t = System.currentTimeMillis() / 1000;
            if (t - timestamp > LATENCY_REFRESH) { // timestamp in seconds)
                timestamp = t;
                AsyncJSON asyncJSON = new AsyncJSON(false); // no circle here (already in SwipeLayout)
                asyncJSON.execute(Constants.URL_JSON_SPONSORS);
            } else {
                swipeRefreshLayout.setRefreshing(false);
            }
        }
    });

    // On click listener
    recList.addOnItemTouchListener(
            new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    SponsorItem si = sponsorItems.get(position);
                    if (si.getUrl() != null && si.getUrl().length() > 0) {
                        String url = si.getUrl();
                        Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setData(Uri.parse(url));
                        startActivity(i);
                    }
                }
            }));

    return rootView;
}

From source file:de.geeksfactory.opacclient.frontend.ResultsAdapter.java

@Override
public View getView(int position, View contentView, ViewGroup viewGroup) {
    View view;//from w  ww  . j av  a 2 s .  c  o m

    // position always 0-7
    if (objects.get(position) == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
        return view;
    }

    SearchResult item = objects.get(position);

    if (contentView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
    } else {
        view = contentView;
    }

    TextView tv = (TextView) view.findViewById(R.id.tvResult);
    tv.setText(Html.fromHtml(item.getInnerhtml()));

    ImageView ivType = (ImageView) view.findViewById(R.id.ivType);

    PreferenceDataSource pds = new PreferenceDataSource(getContext());
    ConnectivityManager connMgr = (ConnectivityManager) getContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    if (item.getCoverBitmap() != null) {
        ivType.setImageBitmap(BitmapUtils.bitmapFromBytes(item.getCoverBitmap()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if ((pds.isLoadCoversOnDataPreferenceSet()
            || !ConnectivityManagerCompat.isActiveNetworkMetered(connMgr)) && item.getCover() != null) {
        LoadCoverTask lct = new LoadCoverTask(ivType, item);
        lct.execute();
        ivType.setImageResource(R.drawable.ic_loading);
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if (item.getType() != null && item.getType() != MediaType.NONE) {
        ivType.setImageResource(getResourceByMediaType(item.getType()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(padding8dp, padding8dp, padding8dp, padding8dp);
    } else {
        ivType.setVisibility(View.INVISIBLE);
    }
    ImageView ivStatus = (ImageView) view.findViewById(R.id.ivStatus);

    if (item.getStatus() != null) {
        ivStatus.setVisibility(View.VISIBLE);
        switch (item.getStatus()) {
        case GREEN:
            ivStatus.setImageResource(R.drawable.status_light_green_check);
            break;
        case RED:
            ivStatus.setImageResource(R.drawable.status_light_red_cross);
            break;
        case YELLOW:
            ivStatus.setImageResource(R.drawable.status_light_yellow_alert);
            break;
        case UNKNOWN:
            ivStatus.setVisibility(View.INVISIBLE);
            break;
        }
    } else {
        ivStatus.setVisibility(View.GONE);
    }

    return view;
}

From source file:com.example.android.sunshine.fragments.ForecastFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_main, container, false);
}

From source file:com.ronnyml.sweetplayer.fragments.SearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_search, container, false);
    mActivity = this.getActivity();
    mArtistsRecyclerView = (RecyclerView) rootView.findViewById(R.id.top_artists_recyclerview);
    mEditText = (EditText) rootView.findViewById(R.id.search_edit_text);
    mLoadingBar = (ProgressBar) rootView.findViewById(R.id.loading_bar);
    mSearchButton = (ImageButton) rootView.findViewById(R.id.search_button);
    mSongsListview = (ObservableListView) rootView.findViewById(R.id.songs_listview);
    mTopArtistsLayout = (LinearLayout) rootView.findViewById(R.id.top_artists_layout);
    mTopSongsLayout = (LinearLayout) rootView.findViewById(R.id.top_songs_layout);

    LinearLayoutManager mArtistsLinearLayoutManager = new LinearLayoutManager(
            mActivity.getApplicationContext());
    mArtistsLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mArtistsRecyclerView.setLayoutManager(mArtistsLinearLayoutManager);
    mArtistsRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mSongsListview.setScrollViewCallbacks(this);
    setupSearchButton();/*  ww  w .  ja  v a2 s  .com*/

    if (Utils.isConnectedToInternet(mActivity)) {
        Intent intent = mActivity.getIntent();
        if (intent != null) {
            if (intent.getBooleanExtra(Constants.IS_SEARCH, false)) {
                search(intent.getStringExtra(Constants.SEARCH_TEXT));
            } else {
                getRequest(Constants.ARTISTS_URL, 0);
                getRequest(Constants.TOP_URL, 1);
            }
        }
    } else {
        Utils.showAlertDialog(mActivity, mActivity.getString(R.string.internet_no_connection_title),
                mActivity.getString(R.string.internet_no_connection_message));
    }

    return rootView;
}

From source file:com.example.run_tracker.RunFragment.java

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

    View rootView = inflater.inflate(R.layout.runfragment, container, false);
    mToken = ((MainActivity) getActivity()).getToken();
    mDistanceText = (TextView) rootView.findViewById(R.id.dst);
    mStatus = (TextView) rootView.findViewById(R.id.status);
    mStatus.setTextColor(Color.RED);
    mStop = (Button) rootView.findViewById(R.id.stop);
    Chronometer mCronometer = (Chronometer) rootView.findViewById(R.id.chronometer1);
    mTimer.setTimer(mCronometer);//  w  ww  .  ja  v  a2  s .  c  o  m
    mStart = (Button) rootView.findViewById(R.id.start);
    mStart.setOnClickListener(this);
    mStop.setOnClickListener(this);
    mMapFragment = CustomMapFragment.newInstance();
    getChildFragmentManager().beginTransaction().replace(R.id.myfragment, mMapFragment).commit();
    if (!mTimer.getFirstStart()) {
        mTimer.startTimer();
    }
    Log.v(TAG, "onCreateView");

    return rootView;

}

From source file:org.openhab.habdroid.ui.OpenHABBindingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    Log.i(TAG, "onCreateView");
    Log.d(TAG, "isAdded = " + isAdded());
    View view = inflater.inflate(R.layout.openhabbindinglist_fragment, container, false);
    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    mSwipeLayout.setOnRefreshListener(this);
    return view;//  ww  w.ja v a  2  s .c o  m
}

From source file:com.mikecorrigan.trainscorekeeper.FragmentHistory.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container
            + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState));

    View rootView = inflater.inflate(R.layout.fragment_history, container, false);

    textView = (TextView) rootView.findViewById(R.id.text_view_history);
    scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view);

    // Get the model and attach a listener.
    MainActivity activity = (MainActivity) getActivity();
    game = activity.getGame();/*from   www . ja  v a  2  s. co  m*/
    if (game != null) {
        game.addListener(mGameListener);
    }

    Bundle args = getArguments();
    if (args == null) {
        Log.e(TAG, "onCreateView: missing arguments");
        return rootView;
    }

    // final int index = args.getInt(ARG_INDEX);
    // final String tabSpec = args.getString(ARG_TAB_SPEC);

    return rootView;
}

From source file:com.elkriefy.android.apps.authenticationexample.fingerprintdialog.FingerprintAuthenticationDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getDialog().setTitle(getString(R.string.sign_in));
    View v = inflater.inflate(R.layout.fingerprint_dialog_container, container, false);
    mCancelButton = (Button) v.findViewById(R.id.cancel_button);
    mCancelButton.setOnClickListener(new View.OnClickListener() {
        @Override//from ww  w  .  j av a2 s .  c  o  m
        public void onClick(View view) {
            dismiss();
        }
    });

    mSecondDialogButton = (Button) v.findViewById(R.id.second_dialog_button);
    mSecondDialogButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mStage == Stage.FINGERPRINT) {
                goToBackup();
            } else {
                verifyPassword();
            }
        }
    });
    mFingerprintContent = v.findViewById(R.id.fingerprint_container);
    mBackupContent = v.findViewById(R.id.backup_container);
    mPassword = (EditText) v.findViewById(R.id.password);
    mPassword.setOnEditorActionListener(this);
    mPasswordDescriptionTextView = (TextView) v.findViewById(R.id.password_description);
    mUseFingerprintFutureCheckBox = (CheckBox) v.findViewById(R.id.use_fingerprint_in_future_check);
    mNewFingerprintEnrolledTextView = (TextView) v.findViewById(R.id.new_fingerprint_enrolled_description);
    mFingerprintUiHelper = mFingerprintUiHelperBuilder.build((ImageView) v.findViewById(R.id.fingerprint_icon),
            (TextView) v.findViewById(R.id.fingerprint_status), this);
    updateStage();

    // If fingerprint authentication is not available, switch immediately to the backup
    // (password) screen.
    if (!mFingerprintUiHelper.isFingerprintAuthAvailable()) {
        goToBackup();
    }
    return v;
}

From source file:com.tapcentive.sdk.actions.TapMessageFragment.java

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

    View view = inflater.inflate(R.layout.fragment_tap_message, parent, false);
    this.gameView = view;
    return view;/*from  w  w  w  .  j a  v  a2s .c  o m*/
}