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.seregil13.literarytracker.lightnovel.LightNovelEditFragment.java

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

    this.mTitleET = (EditText) view.findViewById(R.id.title);
    this.mAuthorET = (EditText) view.findViewById(R.id.author);
    this.mDescriptionET = (EditText) view.findViewById(R.id.description);
    this.mTranslatorSiteET = (EditText) view.findViewById(R.id.translatorSite);
    this.mCompletedCB = (CheckBox) view.findViewById(R.id.completionStatus);
    Button editGenres = (Button) view.findViewById(R.id.genreSelection);
    Button cancel = (Button) view.findViewById(R.id.cancelButton);
    Button save = (Button) view.findViewById(R.id.saveButton);

    cancel.setOnClickListener(this.mCancelListener);
    save.setOnClickListener(this.mSaveListener);
    editGenres.setOnClickListener(new View.OnClickListener() {
        @Override//w w  w. j  av  a2 s.  c  o m
        public void onClick(View v) {
            Intent intent = new Intent(getActivity().getApplicationContext(), GenreSelectionActivity.class);
            intent.putStringArrayListExtra(JsonKeys.GENRES.toString(), mGenres);

            startActivityForResult(intent, LiteraryTrackerUtils.GENRE_REQUEST_CODE);
        }
    });

    mTitleET.setText(mTitle);
    mAuthorET.setText(mAuthor);
    mDescriptionET.setText(mDescription);
    mTranslatorSiteET.setText(mTranslatorSite);
    mCompletedCB.setChecked(Boolean.parseBoolean(mCompleted));

    return view;
}

From source file:com.mercandalli.android.apps.files.user.community.UserLocationFragment.java

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

    this.text = (TextView) rootView.findViewById(R.id.text);
    this.text.setText("Touch the circle to see user positions");

    this.circle = (ImageButton) rootView.findViewById(R.id.circle);

    if (mGoogleMap == null) {
        mapView = (MapView) rootView.findViewById(R.id.mapView);

        mapView.onCreate(savedInstanceState);
        mapView.onResume(); //without this, map showed but was empty

        if (mapView != null) {
            mapView.getMapAsync(new OnMapReadyCallback() {
                @Override/*from  w  w w  .ja  v a2 s .c  o  m*/
                public void onMapReady(final GoogleMap googleMap) {
                    if (isAdded()) {
                        mGoogleMap = googleMap;
                    }
                }
            });

            /*
            map.getUiSettings().setMyLocationButtonEnabled(false);
            map.setMyLocationEnabled(true);
                    
            // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
            MapsInitializer.initialize(this.getActivity());
                    
            // Updates the location and zoom of the MapView
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(44.14, 14.2), 10);
            map.animateCamera(cameraUpdate);
            */
        }

        addLocation(new UserLocationModel("Zero Zero", 0, 0, 0));
    }

    this.circle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogUtils.alert(getContext(), "Share your location",
                    "If you share your location you will see all the positions of every users",
                    getString(android.R.string.yes), new DialogUtils.OnDialogUtilsListener() {
                        @Override
                        public void onDialogUtilsCalledBack() {
                            location = GpsUtils.getGpsLocation(getContext(), new ILocationListener() {
                                @Override
                                public void execute(Location location) {
                                    if (location != null) {
                                        double longitude = location.getLongitude(),
                                                latitude = location.getLatitude();

                                        if (NetUtils.isInternetConnection(getContext()) && longitude != 0
                                                && latitude != 0) {
                                            List<StringPair> parameters = new ArrayList<>();
                                            parameters.add(new StringPair("longitude", "" + longitude));
                                            parameters.add(new StringPair("latitude", "" + latitude));

                                            (new TaskPost(getActivity(),
                                                    Constants.URL_DOMAIN + Config.ROUTE_USER_PUT,
                                                    new IPostExecuteListener() {
                                                        @Override
                                                        public void onPostExecute(JSONObject json,
                                                                String body) {

                                                        }
                                                    }, parameters)).execute();
                                        }
                                    }
                                }
                            });

                            if (location != null) {
                                double longitude = location.getLongitude(), latitude = location.getLatitude();

                                if (NetUtils.isInternetConnection(getContext()) && longitude != 0
                                        && latitude != 0) {
                                    List<StringPair> parameters = new ArrayList<>();
                                    parameters.add(new StringPair("longitude", "" + longitude));
                                    parameters.add(new StringPair("latitude", "" + latitude));

                                    (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_USER_PUT,
                                            new IPostExecuteListener() {
                                                @Override
                                                public void onPostExecute(JSONObject json, String body) {
                                                    refreshMap();
                                                }
                                            }, parameters)).execute();
                                }
                            }
                        }
                    }, getString(android.R.string.no), null);
        }
    });

    refreshMap();

    return rootView;
}

From source file:com.jcertif.android.fragments.MapEventFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getSherlockActivity().getSupportActionBar()
            .setNavigationMode(com.actionbarsherlock.app.ActionBar.NAVIGATION_MODE_STANDARD);
    setRetainInstance(true);// w w w . jav  a2 s.c om
    View rootView = inflater.inflate(R.layout.fragment_map, container, false);

    getActivity().setTitle(R.string.app_name);
    setHasOptionsMenu(true);

    mapv = (MapView) rootView.findViewById(R.id.mapview);
    mapv.onCreate(savedInstanceState);

    onMapReady();

    return rootView;
}

From source file:com.jaspersoft.android.jaspermobile.activities.profile.fragment.ServersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    return inflater.inflate(
            (viewType == ViewType.LIST) ? R.layout.common_list_layout : R.layout.common_grid_layout, container,
            false);//w w w  .  jav  a 2 s  . c o m
}

From source file:com.adithya321.sharesanalysis.fragments.DetailFragment.java

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

    final TextView date = (TextView) rootView.findViewById(R.id.detail_date);
    final TextView open = (TextView) rootView.findViewById(R.id.detail_open);
    final TextView high = (TextView) rootView.findViewById(R.id.detail_high);
    final TextView low = (TextView) rootView.findViewById(R.id.detail_low);
    final TextView last = (TextView) rootView.findViewById(R.id.detail_last);
    final TextView close = (TextView) rootView.findViewById(R.id.detail_close);
    final TextView quantity = (TextView) rootView.findViewById(R.id.detail_quantity);
    final TextView turnover = (TextView) rootView.findViewById(R.id.detail_turnover);

    final SparkView sparkView = (SparkView) rootView.findViewById(R.id.detail_spark_view);

    databaseHandler = new DatabaseHandler(getActivity());
    List<Share> shares = databaseHandler.getShares();
    share = new Share();
    for (Share s : shares) {
        if (s.getName().equals(getArguments().getString(ARG_SHARE_NAME))) {
            share = s;/*from w  w  w . j  av  a 2 s . c  o  m*/
            break;
        }
    }

    String BASE_URL = "https://www.quandl.com/api/v3/datasets/NSE/";
    String url = BASE_URL.concat(StringUtils.getCode(share.getName()) + ".json");
    HttpUrl.Builder urlBuilder = HttpUrl.parse(url).newBuilder();
    urlBuilder.addQueryParameter("api_key", getString(R.string.quandl_api_key));
    url = urlBuilder.build().toString();

    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder().url(url).build();

    client.newCall(request).enqueue(new Callback() {
        @Override
        public void onResponse(Call call, final Response response) throws IOException {
            try {
                String responseData = response.body().string();
                JSONObject j = new JSONObject(responseData);
                j = j.getJSONObject("dataset");
                final JSONArray jsonArray = j.getJSONArray("data");
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            float[] yData = new float[jsonArray.length()];
                            int j = jsonArray.length() - 1;
                            for (int i = 0; i < jsonArray.length(); i++) {
                                try {
                                    yData[j] = Float.parseFloat(jsonArray.getJSONArray(i).get(5).toString());
                                } catch (Exception e) {
                                    //
                                }
                                j--;
                            }
                            sparkView.setAdapter(new SparkViewAdapter(yData));

                            date.setText(jsonArray.getJSONArray(0).get(0).toString());
                            open.setText(jsonArray.getJSONArray(0).get(1).toString());
                            high.setText(jsonArray.getJSONArray(0).get(2).toString());
                            low.setText(jsonArray.getJSONArray(0).get(3).toString());
                            last.setText(jsonArray.getJSONArray(0).get(4).toString());
                            close.setText(jsonArray.getJSONArray(0).get(5).toString());
                            quantity.setText(jsonArray.getJSONArray(0).get(6).toString());
                            turnover.setText(jsonArray.getJSONArray(0).get(7).toString());
                        } catch (Exception e) {
                            Log.e("UI Json", e.toString());
                        }
                    }
                });
            } catch (Exception e) {
                Log.e("DetailFragment Json", e.toString());
            }
        }

        @Override
        public void onFailure(Call call, IOException e) {
            Log.e("DetailFragment onFail", e.toString());
        }
    });

    setSharePurchases(rootView);
    setShareSales(rootView);
    setShareHoldings(rootView);

    return rootView;
}

From source file:fr.cph.chicago.fragment.BikeFragment.java

@Override
public final View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_bike, container, false);
    if (!mActivity.isFinishing()) {
        mLoadingLayout = (RelativeLayout) mRootView.findViewById(R.id.loading_relativeLayout);
        mDesactivatedLayout = (RelativeLayout) mRootView.findViewById(R.id.desactivated_layout);
        mListView = (ListView) mRootView.findViewById(R.id.bike_list);
        mFilterView = (TextView) mRootView.findViewById(R.id.bike_filter);
        if (Util.isNetworkAvailable()) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mActivity);
            boolean loadBike = sharedPref.getBoolean("divvy_bike", true);
            if (loadBike) {
                if (mBikeStations == null || mBikeStations.size() != 0) {
                    loadList();/*from ww w.j av a 2  s  . c  om*/
                } else {
                    mLoadingLayout.setVisibility(RelativeLayout.VISIBLE);
                    mListView.setVisibility(ListView.INVISIBLE);
                    mFilterView.setVisibility(TextView.INVISIBLE);
                    new WaitForRefreshData().execute();
                }
            } else {
                mDesactivatedLayout.setVisibility(RelativeLayout.VISIBLE);
                mFilterView.setVisibility(TextView.INVISIBLE);
            }
        } else {
            Toast.makeText(ChicagoTracker.getAppContext(), "No network connection detected!",
                    Toast.LENGTH_SHORT).show();
        }
    }
    return mRootView;
}

From source file:com.baochu.androidassignment.login.ProfileFragment.java

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

    View view = inflater.inflate(R.layout.profile_fragment, container, false);
    mProfilePictureView = (ProfilePictureView) view.findViewById(R.id.profile_Picture);
    mProfilePictureView.setCropped(true);
    mUserInfo = (TextView) view.findViewById(R.id.user_info);

    mAlbumButton = (Button) view.findViewById(R.id.album_button);
    mAlbumButton.setOnClickListener(new OnClickListener() {
        @Override//  w  ww .ja  v a2 s. c  o  m
        public void onClick(View v) {
            Context context = ProfileFragment.this.getActivity();
            Intent intent = new Intent(context, AlbumActivity.class);
            context.startActivity(intent);
        }
    });

    mLocationButton = (Button) view.findViewById(R.id.location_button);
    mLocationButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Context context = ProfileFragment.this.getActivity();
            Intent intent = new Intent(context, GMSMapActivity.class);
            context.startActivity(intent);
        }
    });

    mGCMMessageButton = (Button) view.findViewById(R.id.gcm_message_button);
    mGCMMessageButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Context context = ProfileFragment.this.getActivity();
            Intent intent = new Intent(context, NotificationEntryActivity.class);
            context.startActivity(intent);
        }
    });

    mStatusListView = (ListView) view.findViewById(R.id.status_list);
    View header = LayoutInflater.from(getActivity()).inflate(R.layout.status_list_header, null);
    mStatusListView.addHeaderView(header, null, false);
    mStatusListAdapter = new StatusListAdapter(getActivity());
    mStatusListView.setAdapter(mStatusListAdapter);

    return view;
}

From source file:org.openhab.habdroid.ui.OpenHABNotificationFragment.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.openhabnotificationlist_fragment, container, false);
    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    mSwipeLayout.setOnRefreshListener(this);
    return view;//from  w ww  . j av  a  2  s.  c  o m
}