GridView setSelection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GridView setSelection method.

This code example shows how to use the following methods:setAdapter, setSelection, setEmptyView, setOnItemClickListener
     */ 
    public void setGridAdapter(ListAdapter adapter) {
        final boolean hadAdapter = (mAdapter != null);
        mAdapter = adapter;
        if (mGrid != null) {
            mGrid.setAdapter(adapter);
            if (!mGridShown && !hadAdapter) {
                // The grid was hidden, and previously didn't have an 
                // adapter.  It is now time to show it. 
                setGridShown(true, (getView().getWindowToken() != null));
            } 
        } 
    } 
 
    /** 
     * Set the currently selected grid item to the specified 
     * position with the adapter's data 
     * 
     * @param position 
     */ 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invalidate, setAdapter, setSelection
				case ITEM_FULLSCREEN:// ȫ��
 
					break; 
				case ITEM_MORE:// ��ҳ
					if (isMore) {
						menuGrid.setAdapter(getMenuAdapter(menu_name_array2,
								menu_image_array2));
						isMore = false;
					} else {// ��ҳ 
						menuGrid.setAdapter(getMenuAdapter(menu_name_array,
								menu_image_array));
						isMore = true;
					} 
					menuGrid.invalidate();// ����menu
					menuGrid.setSelection(ITEM_MORE);
					break; 
				} 
				 
				 
			} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setSelection, setEmptyView, setOnItemClickListener
     */ 
    public void setGridAdapter(ListAdapter adapter) {
        final boolean hadAdapter = (mAdapter != null);
        mAdapter = adapter;
        if (mGrid != null) {
            mGrid.setAdapter(adapter);
            if (!mGridShown && !hadAdapter) {
                // The grid was hidden, and previously didn't have an 
                // adapter.  It is now time to show it. 
                setGridShown(true, (getView().getWindowToken() != null));
            } 
        } 
    } 
 
    /** 
     * Set the currently selected grid item to the specified 
     * position with the adapter's data 
     * 
     * @param position 
     */ 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSelection, getCount
		super.leaveSelectionMode(); 
	} 
 
	@Override 
	public void moveFolder(int position) {
		if (position >= mGridView.getCount()) {
			return; 
		} 
		mGridView.setSelection(position);
	} 
	 
    @Override 
    public boolean onDrag(View v, DragEvent event) {
        boolean flag = super.onDrag(v, event);
        switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_EXITED:
        case DragEvent.ACTION_DROP:
        case DragEvent.ACTION_DRAG_ENDED:
            v.setBackgroundResource(R.drawable.folder_view_list_grid_selector);
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setSelection, getFirstVisiblePosition
    public void onLoadFinished(Loader<MessagesArtistsResponse> loader, MessagesArtistsResponse data) {
        if(data != null){
            mAdapter.setData(data.getArtists());
            mNextPage = data.getNextPage();
        } 
        int currPostion = mGridView.getFirstVisiblePosition();
        mGridView.setAdapter(mAdapter);
        mGridView.setSelection(currPostion); //When updating adapter, it wants to scroll to top
        mProgressBar.setVisibility(View.INVISIBLE);
    } 
 
    @Override 
    public void onLoaderReset(Loader<MessagesArtistsResponse> loader) {
        mAdapter.setData(null);
    } 
 
 
    @Override 
    public void endOfListReached() { 
        // When the end of the list is reached, load the new data 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invalidate, setAdapter, setSelection
					if (isMore) {
						menuGrid.setAdapter(getMenuAdapter(mContext,
								menuMoreNameArray, menuMoreImageArray));
						isMore = false;
					} else { 
						menuGrid.setAdapter(getMenuAdapter(mContext,
								menuNameArray, menuImageArray));
						isMore = true;
					} 
					menuGrid.invalidate();
					menuGrid.setSelection(ITEM_MORE);
					break; 
				} 
 
			} 
		}); 
	} 
 
	private SimpleAdapter getMenuAdapter(Context context,
			String[] menuNameArray, int[] imageResourceArray) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setSelection, setEmptyView, setOnItemClickListener
     */ 
    public void setListAdapter(ListAdapter adapter) {
        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mGrid != null) {
            mGrid.setAdapter(adapter);
            if (!mGridShown && !hadAdapter) {
                // The grid was hidden, and previously didn't have an 
                // adapter. It is now time to show it. 
                setGridShown(true, getView().getWindowToken() != null);
            } 
        } 
    } 
 
    /** 
     * Set the currently selected grid item to the specified position with the 
     * adapter's data 
     * 
     * @param position 
     */ 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:invalidate, setAdapter, setSelection
					if (isMore) {
						menuGrid.setAdapter(getMenuAdapter(mContext,
								menuMoreNameArray, menuMoreImageArray));
						isMore = false;
					} else { 
						menuGrid.setAdapter(getMenuAdapter(mContext,
								menuNameArray, menuImageArray));
						isMore = true;
					} 
					menuGrid.invalidate();
					menuGrid.setSelection(ITEM_MORE);
					break; 
				} 
 
			} 
		}); 
	} 
 
	private SimpleAdapter getMenuAdapter(Context context,
			String[] menuNameArray, int[] imageResourceArray) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setSelection
	    public void setVideos(ArrayList<Item> videos) {
	    	if (videos == null || videos.size() == 0) {
	    		Log.w(TAG , "Empty videos list");
	    	} else { 
	    		mAdapter = new GridAdapter(mContext, videos);
		    	mGridView.setAdapter(mAdapter);
		    	mGridView.setSelection(itemPosition);
	    	} 
	    } 
	     
	     
		public void click(int position) {
 
 
		} 
		 
		public Context getContext()  {
			return mContext;
		} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setSelection, getFirstVisiblePosition
 
	    @Override 
	    protected void onPostExecute(Void result) {
 
	        // get listview current position - used to maintain scroll position 
	        int currentPosition = gridOfPhotos.getFirstVisiblePosition();
 
	        // APPEND NEW DATA TO THE ARRAYLIST AND SET THE ADAPTER TO THE 
	        // LISTVIEW 
	        adapter = new PhotosAdapter(MainActivity.this, arrPhotos);
	        gridOfPhotos.setAdapter(adapter);
 
	        spin2.setVisibility(View.GONE);
	        // Setting new scroll position 
	        gridOfPhotos.setSelection(currentPosition + 1);
 
	        // SET LOADINGMORE "FALSE" AFTER ADDING NEW FEEDS TO THE EXISTING 
	        // LIST 
	        loadingMore = false;
	    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related GridView setSelection Questions & Answers:

setSelection Method Overview
Sets the currently selected item
See Code Examples for other Android GridView Methods: