android.widget.GridView.getAdapter()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中android.widget.GridView.getAdapter()方法的一些代码示例,展示了GridView.getAdapter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getAdapter()方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getAdapter

GridView.getAdapter介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

imgbtn_show_smileys.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View arg0) {
     final Dialog groupIconsDialog = new Dialog(UserChatActivity.this);
     groupIconsDialog.setTitle("Choose Group Icon");
     groupIconsDialog.setContentView(R.layout.group_icons_layout);
     //calling and setting the image icons to the grid view adapter
     final GridView groupIconsGrid = (GridView)groupIconsDialog.findViewById(R.id.grid_groupIcons);
     groupIconsGrid.setAdapter(new SmileysAdapter(arrayListSmileys, UserChatActivity.this, emoticons));
     groupIconsGrid.setOnItemClickListener(new OnItemClickListener() {
       @Override
       public void onItemClick(AdapterView<?> arg0, View arg1,
           int position, long arg3) {
         // TODO Auto-generated method stub
         String value = groupIconsGrid.getAdapter().getItem(position).toString();
         value = editMessage.getText()+value;
         Spannable spannable = getSmiledText(UserChatActivity.this, value);
         editMessage.setText(spannable);
         groupIconsDialog.dismiss();
       }
     });
     groupIconsDialog.show();
   }
 });

代码示例来源:origin: p-v/FlexibleCalendar

private void reAddAdapter(View view) {
  if (view != null) {
    ListAdapter adapter = ((GridView) view).getAdapter();
    ((GridView) view).setAdapter(adapter);
  }
}

代码示例来源:origin: stackoverflow.com

GridView glist = (GridView) findViewById(R.id.tipss_grid);
if (glist.getAdapter() == null) {
  CurrentAdapter adapter2 = new CurrentAdapter(CurrentChanels.this,
     array_list);
  glist.setAdapter(adapter2);
} else {
  CurrentAdapter adapter2 = ((CurrentAdapter)glist.getAdapter());
  adapter2.resetData(array_list);
}

代码示例来源:origin: tdscientist/fluidCalendar

private void reAddAdapter(View view) {
  if (view != null) {
    ListAdapter adapter = ((GridView) view).getAdapter();
    ((GridView) view).setAdapter(adapter);
  }
}

代码示例来源:origin: pranavpandey/dynamic-support

/**
 * Set selected color for the grid views containing colors.
 *
 * @param gridView The grid view to select the color.
 * @param color The color to be selected.
 */
private void setSelectedColor(@NonNull GridView gridView, @ColorInt int color) {
  if (gridView.getAdapter() != null) {
    ((DynamicColorsAdapter) gridView.getAdapter()).setSelectedColor(color);
  }
}

代码示例来源:origin: stackoverflow.com

public View getViewByPosition(int pos, GridView gridView) {
  final int firstListItemPosition = listView.getFirstVisiblePosition();
  final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;

  if (pos < firstListItemPosition || pos > lastListItemPosition ) {
    return gridView.getAdapter().getView(pos, null, listView);
  } else {
    final int childIndex = pos - firstListItemPosition;
    return gridView.getChildAt(childIndex);
  }
}

代码示例来源:origin: stackoverflow.com

final GridView grid = new GridView(this); // Could be findViewById(R.id.grid) 
   grid.setAdapter(new ArrayAdapter<String>(this, android.R.id.text1)); // Use your own Adapter with real data
   grid.setOnItemClickListener(new OnItemClickListener()
   {
     @Override
     public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
     {
       //Do something - change the data of the List/Array/etc
       // Now you can try this:
       ((ArrayAdapter<String>)grid.getAdapter()).notifyDataSetChanged();
       // Or this:
       grid.setAdapter(new ArrayAdapter<String>(MyActivity.this, android.R.id.text1));
     }
   });

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@SuppressWarnings("unchecked")
  @Override
  public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Entry<String, Object> item = (Entry<String, Object>) gridView.getAdapter().getItem(arg2);
    PreferenceType type = PreferenceType.fromObject(item.getValue());
    if (type == PreferenceType.UNSUPPORTED) {
      Toast.makeText(getActivity(), R.string.preference_unsupported, Toast.LENGTH_SHORT).show();
    } else {
      showPrefDialog(type, true, item.getKey(), item.getValue());
    }
  }
});

代码示例来源:origin: marzika/Snapprefs

@Override
  protected void onPostExecute(Void aVoid) {
    progress.dismiss();
    ((FilterAdapter) gridView.getAdapter()).notifyDataSetChanged();
    gridView.invalidateViews();
    loading = false;
  }
}

代码示例来源:origin: sphinx02/AppStarter

@Override
public void onResume()
{
  super.onResume();
  if (mHasBeenInOnPauseButNotInDestroy)
  {
    // Reload app order
    Log.d(MainActivity.class.getName(), "Reloading Order.");
    InstalledAppsAdapter actAdapter = (InstalledAppsAdapter) mGridView.getAdapter();
    actAdapter.loadInstalledApps();
    actAdapter.notifyDataSetChanged();
  }
}

代码示例来源:origin: youtube/yt-direct-lite-android

@Override
public void onConnected(Bundle bundle) {
  if (mGridView.getAdapter() != null) {
    ((UploadedVideoAdapter) mGridView.getAdapter()).notifyDataSetChanged();
  }
  setProfileInfo();
  mCallbacks.onConnected(Plus.AccountApi.getAccountName(mGoogleApiClient));
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

private boolean updateFilter(String s) {
  String filter = !TextUtils.isEmpty(s) ? s.trim() : null;
  PreferenceAdapter adapter = ((PreferenceAdapter) gridView.getAdapter());
  if (adapter == null) {
    return false;
  }
  adapter.setFilter(filter);
  adapter.getFilter().filter(filter);
  return true;
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

private void setSortType(PreferenceSortType type) {
  if (PreferencesActivity.preferenceSortType != type) {
    PreferencesActivity.preferenceSortType = type;
    if (getActivity() != null) {
      getActivity().invalidateOptionsMenu();
      PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putInt(PreferencesActivity.KEY_SORT_TYPE, type.ordinal()).commit();
    }
    if (gridView.getAdapter() != null && preferenceFile != null) {
      preferenceFile.updateSort();
      ((PreferenceAdapter) gridView.getAdapter()).notifyDataSetChanged();
    }
  }
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
  ((PreferenceAdapter) gridView.getAdapter()).itemCheckedStateChanged(position, checked);
  mode.setTitle(Html.fromHtml("<b>" + gridView.getCheckedItemCount() + "</b>"));
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@Override
public void onDestroyActionMode(ActionMode mode) {
  ((PreferenceAdapter) gridView.getAdapter()).resetSelection();
  getActivity().invalidateOptionsMenu();
}

代码示例来源:origin: stackoverflow.com

public static void setHeightDynamically(GridView listView) {
   ListAdapter listAdapter = listView.getAdapter();
   if (listAdapter == null)
     return;
   int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
   int totalHeight = 0;
   View view = null;
   for (int i = 0; i < listAdapter.getCount(); i = i+2) {
     view = listAdapter.getView(i, view, listView);
     view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
     totalHeight += view.getMeasuredHeight();
   }
   ViewGroup.LayoutParams params = listView.getLayoutParams();
   params.height = totalHeight;
   listView.setLayoutParams(params);
   listView.requestLayout();
 }

代码示例来源:origin: googlecodelabs/android-topeka

private void setUpUserInput() {
  mAnswerView.performItemClick(mAnswerView.getChildAt(mAnswered), mAnswered,
      mAnswerView.getAdapter().getItemId(mAnswered));
  mAnswerView.getChildAt(mAnswered).setSelected(true);
  mAnswerView.setSelection(mAnswered);
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

public void addPrefKeyValue(String previousKey, String newKey, Object value, boolean editMode) {
  if (preferenceFile == null) {
    return;
  }
  preferenceFile.add(previousKey, newKey, value, editMode);
  Utils.savePreferences(preferenceFile, mFile, mPackageName, getActivity());
  ((PreferenceAdapter) gridView.getAdapter()).notifyDataSetChanged();
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

public void deletePref(String key) {
  if (preferenceFile == null) {
    return;
  }
  preferenceFile.removeValue(key);
  Utils.savePreferences(preferenceFile, mFile, mPackageName, getActivity());
  ((PreferenceAdapter) gridView.getAdapter()).notifyDataSetChanged();
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
  switch (item.getItemId()) {
    case R.id.action_delete:
      ((PreferenceAdapter) gridView.getAdapter()).deleteSelection();
      Utils.savePreferences(preferenceFile, mFile, mPackageName, getActivity());
      ((PreferenceAdapter) gridView.getAdapter()).notifyDataSetChanged();
      mode.finish();
      return true;
    case R.id.action_select_all:
      boolean check = gridView.getCheckedItemCount() != gridView.getCount();
      for (int i = 0; i < gridView.getCount(); i++) {
        gridView.setItemChecked(i, check);
      }
      return true;
    default:
      return false;
  }
}

相关文章

GridView类方法