Example usage for android.view LayoutInflater getContext

List of usage examples for android.view LayoutInflater getContext

Introduction

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

Prototype

public Context getContext() 

Source Link

Document

Return the context we are running in, for access to resources, class loader, etc.

Usage

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

/**
 * Select a custom item from a list, and call halder when/if item is selected.
 *///from   www .j a  v a 2  s  . c om
public static void selectItemDialog(LayoutInflater inflater, String message, ArrayList<SimpleDialogItem> items,
        SimpleDialogItem selectedItem, final SimpleDialogOnClickListener handler) {
    // Get the view and the radio group
    final View root = inflater.inflate(R.layout.select_list_dialog, null);
    TextView msg = (TextView) root.findViewById(R.id.message);

    // Build the base dialog
    final AlertDialog.Builder builder = new AlertDialog.Builder(inflater.getContext()).setView(root);
    if (message != null && !message.equals("")) {
        msg.setText(message);
    } else {
        msg.setVisibility(View.GONE);
    }

    final AlertDialog dialog = builder.create();

    // Create the listener for each item
    OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            SimpleDialogItem item = (SimpleDialogItem) ViewTagger.getTag(v, R.id.TAG_DIALOG_ITEM);
            // For a consistent UI, make sure the selector is checked as well. NOT mandatory from
            // a functional point of view, just consistent
            if (!(v instanceof RadioButton)) {
                RadioButton btn = item.getSelector(v);
                if (btn != null) {
                    btn.setChecked(true);
                    btn.invalidate();
                }
            }
            //
            // It would be nice to have the other radio buttons reflect the new state before it
            // disappears, but not really worth the effort. Esp. since the code below does not work...
            // and the dialog disappears too fast to make this worthwhile.
            //
            //LinearLayout list = (LinearLayout)root.findViewById(R.id.list);
            //for(int i = 0; i < list.getChildCount(); i++) {
            //   View child = list.getChildAt(i);
            //   SimpleDialogItem other = (SimpleDialogItem)ViewTagger.getTag(child, R.id.TAG_DIALOG_ITEM);
            //   RadioButton btn = other.getSelector(child);
            //   btn.setSelected(other == item);
            //   btn.invalidate();
            //}
            dialog.dismiss();
            handler.onClick(item);
        }
    };

    // Add the items to the dialog
    LinearLayout list = (LinearLayout) root.findViewById(R.id.list);
    for (SimpleDialogItem item : items) {
        View v = item.getView(inflater);
        v.setBackgroundResource(android.R.drawable.list_selector_background);
        ViewTagger.setTag(v, R.id.TAG_DIALOG_ITEM, item);
        list.addView(v);
        v.setOnClickListener(listener);
        RadioButton btn = item.getSelector(v);
        if (btn != null) {
            ViewTagger.setTag(btn, R.id.TAG_DIALOG_ITEM, item);
            btn.setChecked(item == selectedItem);
            btn.setOnClickListener(listener);
        }
    }
    dialog.show();
}

From source file:com.albedinsky.android.support.intent.inner.TestFragment.java

@Nullable
@Override//www.  j a  va2  s . c  o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return new View(inflater.getContext());
}

From source file:com.yek.keyboard.ui.dev.LogCatViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ArrayAdapter<String> adapter = new ArrayAdapter<>(inflater.getContext(),
            android.R.layout.simple_list_item_1, Logger.getAllLogLinesList());
    setListAdapter(adapter);//from w w w . j a  v a  2  s  .  c o m
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.iangclifton.auid.appendixc.sections.LoadingIndicatorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mWebView = new WebView(inflater.getContext());
    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override/* w w w .  j a  va2  s.  com*/
        public void onProgressChanged(WebView view, int progress) {
            getActivity().setProgress(progress * 100);
        }
    });
    return mWebView;
}

From source file:com.appdynamics.demo.gasp.fragment.ReviewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context mContext = inflater.getContext();
    String mBaseUrl = Preferences.getGaspServerUrl().replaceAll("/$", "");

    ReviewDataAdapter mReviewAdapter = new ReviewDataAdapter(inflater.getContext());
    mReviewAdapter.open();// w ww .  ja  v  a2  s .  com

    // Get all reviews in descending order
    mReviews = mReviewAdapter.getAllDesc();
    ArrayAdapter<Review> adapter = new ArrayAdapter<Review>(inflater.getContext(),
            android.R.layout.simple_list_item_1, mReviews);
    mReviewAdapter.close();

    setListAdapter(adapter);
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.anysoftkeyboard.ui.dev.LogCatViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ArrayAdapter<String> adapter = new ArrayAdapter<>(inflater.getContext(),
            android.R.layout.simple_list_item_1, Log.getAllLogLinesList());
    setListAdapter(adapter);//from  w ww  .j  a v  a2s .c  o  m
    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.appdynamics.demo.gasp.fragment.UsersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    UserDataAdapter userDataAdapter = new UserDataAdapter(inflater.getContext());
    userDataAdapter.open();/*ww  w . jav a 2s .  co m*/

    // Get all users in descending order
    List<User> users = userDataAdapter.getAllDesc();
    userDataAdapter.close();
    ArrayAdapter<User> adapter = new ArrayAdapter<User>(inflater.getContext(),
            android.R.layout.simple_list_item_1, users);
    setListAdapter(adapter);

    return super.onCreateView(inflater, container, savedInstanceState);
}

From source file:com.technoxist.fragment.SwipeRefreshFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRefreshLayout = new SwipeRefreshLayout(inflater.getContext());
    inflateView(inflater, mRefreshLayout, savedInstanceState);

    return mRefreshLayout;
}

From source file:org.berlin_vegan.bvapp.fragments.LocationMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mResourceProxy = new ResourceProxyImpl(inflater.getContext().getApplicationContext());
    mMapView = new MapView(inflater.getContext(), mResourceProxy);

    mMapView.getController().setInvertedTiles(false);

    mMapView.setTileSource(UiUtils.GOOGLE_MAPS_TILE);
    mMapView.setMultiTouchControls(true);

    mOverlayItemList = new ArrayList<>();
    mLocationOverlay = new ItemizedIconOverlay<>(getContext(), mOverlayItemList, null);
    mMapView.getOverlays().add(mLocationOverlay);

    return mMapView;
}

From source file:com.appdynamics.demo.gasp.fragment.RestaurantsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RestaurantDataAdapter mRestaurantAdapter = new RestaurantDataAdapter(inflater.getContext());
    mRestaurantAdapter.open();//from   w  w  w  .  ja v a 2  s .  co  m

    // Get all restaurants in descending order
    mRestaurants = mRestaurantAdapter.getAllDesc();
    mRestaurantAdapter.close();

    ArrayAdapter<Restaurant> adapter = new ArrayAdapter<Restaurant>(inflater.getContext(),
            android.R.layout.simple_list_item_1, mRestaurants);
    setListAdapter(adapter);

    return super.onCreateView(inflater, container, savedInstanceState);
}