Java Code Examples for android.widget.ListView.getContext()

The following are Jave code examples for showing how to use getContext() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: simple-upnp   File: ServerBrowserFragment.java   View Source Code Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    RelativeLayout relativeLayoutView = (RelativeLayout)  inflater.inflate(R.layout.fragment_server_browser, container, false);

    ListView serverListView = (ListView) relativeLayoutView.findViewById(R.id.server_browser_list);
    mServerListAdapter =
            new ArrayAdapter<>(serverListView.getContext(), R.layout.fragment_server_browser_item);
    serverListView.setAdapter(mServerListAdapter);
    serverListView.setOnItemClickListener(this);

    mBookmarkTextView = (TextView) relativeLayoutView.findViewById(R.id.bookmarks_text);

    ListView bookmarkListView = (ListView) relativeLayoutView.findViewById(R.id.bookmarks_list);
    mBookmarkListAdapter =
            new ArrayAdapter<>(bookmarkListView.getContext(), R.layout.fragment_server_browser_item);
    bookmarkListView.setAdapter(mBookmarkListAdapter);
    bookmarkListView.setOnItemClickListener(this);

    return relativeLayoutView;
}
 
Example 2
Project: NoticeDog   File: SwipeDismissListViewTouchListener.java   View Source Code Vote up 5 votes
public SwipeDismissListViewTouchListener(ListView listView, DismissCallbacks callbacks) {
    ViewConfiguration vc = ViewConfiguration.get(listView.getContext());
    this.mSlopX = vc.getScaledTouchSlop() * 2;
    this.mSlopY = vc.getScaledTouchSlop();
    this.mAnimationTime = (long) listView.getContext().getResources().getInteger(17694720);
    this.mListView = listView;
    this.mCallbacks = callbacks;
    this.mSwipeToDismissViewResourceId = -1;
    this.gestureDetector = new GestureDetector(listView.getContext(), new GestureRecognizer());
}
 
Example 3
Project: simple-upnp   File: FileBrowserFragment.java   View Source Code Vote up 5 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    ListView view = (ListView) inflater.inflate(R.layout.fragment_file_browser, container, false);
    Context context = view.getContext();

    mFileBrowserAdapter = new FileBrowserAdapter(this, context, R.layout.fragment_file_browser_item);
    mFileBrowserAdapter.add(FileBrowserAdapter.ListItem.PREVIOUS_CONTAINER_LIST_ITEM);
    view.setAdapter(mFileBrowserAdapter);
    view.setOnItemClickListener(this);
    return view;
}
 
Example 4
Project: GravityBox   File: TileOrderActivity.java   View Source Code Vote up 5 votes
void showMenu(final ListView listView, final View anchorView) {
    final PopupMenu menu = new PopupMenu(listView.getContext(), anchorView);
    menu.inflate(R.menu.tile_menu);
    menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.tile_dual:
                    dual = !dual;
                    break;
                case R.id.tile_locked:
                    locked = !locked;
                    if (locked) {
                        secured = true;
                        lockedOnly = false;
                    }
                    break;
                case R.id.tile_locked_only:
                    lockedOnly = !lockedOnly;
                    break;
                case R.id.tile_secured:
                    secured = !secured;
                    break;
            }
            updateMenu(menu.getMenu());
            listView.invalidateViews();
            return true;
        }
    });
    updateMenu(menu.getMenu());
    menu.show();
}
 
Example 5
Project: DereHelper   File: Utils.java   View Source Code Vote up 5 votes
public static void setLVEmptyView(ListView listView, String txt) {
    TextView emptyView = new TextView(listView.getContext());
    emptyView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    emptyView.setText(txt);
    emptyView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
    emptyView.setVisibility(View.GONE);
    ((ViewGroup) listView.getParent()).addView(emptyView);
    listView.setEmptyView(emptyView);
}