List of usage examples for android.widget AdapterView setAdapter
public abstract void setAdapter(T adapter);
From source file:com.handlerexploit.prime.example.activities.GridViewExample.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_content); mLazyImageAdapter = new LazyImageAdapter(this, R.layout.grid_item); @SuppressWarnings("unchecked") AdapterView<LazyImageAdapter> adapterView = (AdapterView<LazyImageAdapter>) findViewById(android.R.id.list); adapterView.setEmptyView(findViewById(R.id.progressContainer)); adapterView.setAdapter(mLazyImageAdapter); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.handlerexploit.prime.example.activities.ListViewExample.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_content); mLazyImageAdapter = new LazyImageAdapter(this, R.layout.list_item); @SuppressWarnings("unchecked") AdapterView<LazyImageAdapter> adapterView = (AdapterView<LazyImageAdapter>) findViewById(android.R.id.list); adapterView.setEmptyView(findViewById(R.id.progressContainer)); adapterView.setAdapter(mLazyImageAdapter); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Sets the adapter of a adapter view./*from w ww. ja v a 2 s . c o m*/ * * @param viewId * The view id. * @param adapter * The adapter; * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setAdapter(int viewId, Adapter adapter) { AdapterView view = retrieveView(viewId); view.setAdapter(adapter); return this; }
From source file:rtdc.android.presenter.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar); // Attaching the layout to the toolbar object setSupportActionBar(toolbar); // Setting toolbar as the ActionBar with setSupportActionBar() call title = getTitle();//w w w . ja v a2s. c o m getSupportActionBar().setDisplayHomeAsUpEnabled(false); // NAVIGATION LIST VIEW AdapterView navListView = (AdapterView) findViewById(R.id.nav_list); // Set the drawer menu contents depending on what the user's permission is User sessionUser = (User) Cache.getInstance().get("sessionUser"); ArrayList<FragmentType> fragmentTypes = new ArrayList<>(); if (sessionUser.getPermission().equals(User.Permission.ADMIN)) { fragmentTypes = new ArrayList<FragmentType>(Arrays.asList(FragmentType.PROFILE, FragmentType.MANAGE_USERS, FragmentType.MANAGE_UNITS, FragmentType.MESSAGES)); } else if (sessionUser.getPermission().equals(User.Permission.MANAGER)) fragmentTypes = new ArrayList<FragmentType>(Arrays.asList(FragmentType.PROFILE, FragmentType.CAPACITY_OVERVIEW, FragmentType.ACTION_PLAN, FragmentType.MESSAGES)); else if (sessionUser.getPermission().equals(User.Permission.USER)) fragmentTypes = new ArrayList<FragmentType>( Arrays.asList(FragmentType.PROFILE, FragmentType.ACTION_PLAN, FragmentType.MESSAGES)); adapter = new navAdapter(fragmentTypes, this); navListView.setAdapter(adapter); // DRAWER MENU drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.action_new, R.string.action_delete) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); setTitle(title); invalidateOptionsMenu(); syncState(); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); syncState(); } }; Button buttonSignOut = (Button) findViewById(R.id.button_sign_out); buttonSignOut.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, LoginActivity.class); Bootstrapper.getFactory().getStorage().remove(Storage.KEY_AUTH_TOKEN); Service.logout(); startActivity(intent); finish(); } }); drawerLayout.setDrawerListener(drawerToggle); // Doing this check first prevents the fragment from being reloaded to home fragment when the screen orientation is changed if (savedInstanceState == null) { if (getIntent() != null) onNewIntent(getIntent()); if (fragment == null) selectItem(1); } }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
/** * Set the adapter of an AdapterView./*from ww w. j a v a 2 s.c o m*/ * @param adapter adapter * @return self */ @SuppressWarnings({ "unchecked", "rawtypes" }) public T adapter(Adapter adapter) { if (view instanceof AdapterView) { AdapterView av = (AdapterView) view; av.setAdapter(adapter); } return self(); }
From source file:com.androidquery.AQuery.java
/** * Set the adapter of an AdapterView./* w w w . ja v a 2s . c o m*/ * * @param adapter adapter * @return self */ @SuppressWarnings({ "unchecked", "rawtypes" }) public AQuery adapter(Adapter adapter) { if (view instanceof AdapterView) { AdapterView av = (AdapterView) view; av.setAdapter(adapter); } return self(); }
From source file:com.androidquery.AbstractAQuery.java
/** * Set the adapter of an AdapterView.//from www . j a v a 2s. co m * * @param adapter adapter * @return self */ @SuppressWarnings({ "unchecked", "rawtypes" }) public T adapter(Adapter adapter) { if (view instanceof AdapterView) { AdapterView av = (AdapterView) view; av.setAdapter(adapter); } return self(); }
From source file:com.brandroidtools.filemanager.fragments.NavigationFragment.java
/** * Method that change the view mode./*from ww w . ja va2 s.co m*/ * * @param newMode The new mode */ @SuppressWarnings({ "unchecked", "null" }) public void changeViewMode(final NavigationLayoutMode newMode) { synchronized (this.mSync) { //Check that it is really necessary change the mode if (this.mCurrentMode != null && this.mCurrentMode.compareTo(newMode) == 0) { return; } // If we should set the listview to response to flinger gesture detection boolean useFlinger = Preferences.getSharedPreferences().getBoolean( FileManagerSettings.SETTINGS_USE_FLINGER.getId(), ((Boolean) FileManagerSettings.SETTINGS_USE_FLINGER.getDefaultValue()).booleanValue()); //Creates the new layout AdapterView<ListAdapter> newView = null; int itemResourceId = -1; if (newMode.compareTo(NavigationLayoutMode.ICONS) == 0) { newView = (AdapterView<ListAdapter>) mNavigationViewHolder.inflate(mActivity, RESOURCE_MODE_ICONS_LAYOUT, null); itemResourceId = RESOURCE_MODE_ICONS_ITEM; } else if (newMode.compareTo(NavigationLayoutMode.SIMPLE) == 0) { newView = (AdapterView<ListAdapter>) mNavigationViewHolder.inflate(mActivity, RESOURCE_MODE_SIMPLE_LAYOUT, null); itemResourceId = RESOURCE_MODE_SIMPLE_ITEM; // Set the flinger listener (only when navigate) if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { if (useFlinger && newView instanceof FlingerListView) { ((FlingerListView) newView).setOnItemFlingerListener(this.mOnItemFlingerListener); } } } else if (newMode.compareTo(NavigationLayoutMode.DETAILS) == 0) { newView = (AdapterView<ListAdapter>) mNavigationViewHolder.inflate(mActivity, RESOURCE_MODE_DETAILS_LAYOUT, null); itemResourceId = RESOURCE_MODE_DETAILS_ITEM; // Set the flinger listener (only when navigate) if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { if (useFlinger && newView instanceof FlingerListView) { ((FlingerListView) newView).setOnItemFlingerListener(this.mOnItemFlingerListener); } } } //Get the current adapter and its adapter list List<FileSystemObject> files = new ArrayList<FileSystemObject>(this.mFiles); final AdapterView<ListAdapter> current = (AdapterView<ListAdapter>) getView() .findViewById(RESOURCE_CURRENT_LAYOUT); FileSystemObjectAdapter adapter = new FileSystemObjectAdapter(mActivity, new ArrayList<FileSystemObject>(), itemResourceId, this.mNavigationMode.compareTo(NAVIGATION_MODE.PICKABLE) == 0); adapter.setOnSelectionChangedListener(this); //Remove current layout if (current != null) { if (current.getAdapter() != null) { //Save selected items before dispose adapter FileSystemObjectAdapter currentAdapter = ((FileSystemObjectAdapter) current.getAdapter()); adapter.setSelectedItems(currentAdapter.getSelectedItems()); currentAdapter.dispose(); } mNavigationViewHolder.removeView(current); } this.mFiles = files; adapter.addAll(files); adapter.notifyDataSetChanged(); //Set the adapter this.mAdapter = adapter; newView.setAdapter(this.mAdapter); newView.setOnItemClickListener(NavigationFragment.this); //Add the new layout this.mAdapterView = newView; mNavigationViewHolder.addView(newView, 0); this.mCurrentMode = newMode; // Pick mode doesn't implements the onlongclick if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { this.mAdapterView.setOnItemLongClickListener(this); } else { this.mAdapterView.setOnItemLongClickListener(null); } //Save the preference (only in navigation browse mode) if (this.mNavigationMode.compareTo(NAVIGATION_MODE.BROWSABLE) == 0) { try { Preferences.savePreference(FileManagerSettings.SETTINGS_LAYOUT_MODE, newMode, true); } catch (Exception ex) { Log.e(TAG, "Save of view mode preference fails", ex); //$NON-NLS-1$ } } } }