类android.widget.BaseAdapter源码实例Demo

下面列出了怎么用android.widget.BaseAdapter的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = (BaseAdapter)parent.getAdapter();
	String emotion = (String)adapter.getItem(position);
       if (StringUtil.isEmpty(emotion)) {
       	return;
       }
       
	EditText etText = (EditText)((Activity)context).findViewById(R.id.etText);
	int currentPos = 0;
	if (etText != null) {
		currentPos = etText.getSelectionStart();
		etText.getText().insert(currentPos, emotion);
	}

}
 
源代码2 项目: admobadapter   文件: AdmobExpressAdapterWrapper.java
/**
 * Sets underlying adapter with your data collection.
 * If you want to inject your implementation of {@link AdmobAdapterCalculator} please set it before this call
 */
public Builder setAdapter(BaseAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
    return this;
}
 
源代码3 项目: admobadapter   文件: AdmobBannerAdapterWrapper.java
/**
 * Sets underlying adapter with your data collection.
 * If you want to inject your implementation of {@link AdmobAdapterCalculator} please set it before this call
 */
public Builder setAdapter(BaseAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            notifyDataSetChanged();
        }

        @Override
        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
    return this;
}
 
源代码4 项目: UniversalAdapter   文件: BaseAdapterConverter.java
/**
 * Binds this adapter to the given {@link AdapterView}, setting it as its adapter. This should be done by
 * construction or immediately after, before this adapter is used. This mechanism sets this class as the view's
 * adapter and permits certain functionality such as click events. Without it, this class will still function as
 * a normal {@link BaseAdapter}, but additional functionality may not work. Ignore this step at your own risk.
 *
 * @param adapterView The {@link AdapterView} to bind to.
 */
public void bindToAdapterView(AdapterView<? super BaseAdapter> adapterView) {
    if (adapterView != null) {
        adapterView.setAdapter(this);

        // Spinners don't like on item click listeners.
        // We will still delegate calls to it since you're clicking on an item to select it...
        if (!(adapterView instanceof Spinner)) {
            adapterView.setOnItemClickListener(internalItemClickListener);
        } else {
            adapterView.setOnItemSelectedListener(internalItemSelectedListener);
        }

        adapterView.setOnItemLongClickListener(internalLongClickListener);
    }
}
 
源代码5 项目: sketch   文件: ScrollingPauseLoadManager.java
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    if (AppConfig.INSTANCE.getBoolean(view.getContext(), AppConfig.Key.SCROLLING_PAUSE_LOAD) && view.getAdapter() != null) {
        ListAdapter listAdapter = view.getAdapter();
        if (listAdapter instanceof WrapperListAdapter) {
            listAdapter = ((WrapperListAdapter) listAdapter).getWrappedAdapter();
        }
        if (listAdapter instanceof BaseAdapter) {
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                if (!sketch.getConfiguration().isPauseLoadEnabled()) {
                    sketch.getConfiguration().setPauseLoadEnabled(true);
                }
            } else if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
                if (sketch.getConfiguration().isPauseLoadEnabled()) {
                    sketch.getConfiguration().setPauseLoadEnabled(false);
                    ((BaseAdapter) listAdapter).notifyDataSetChanged();
                }
            }
        }
    }

    if (absListScrollListener != null) {
        absListScrollListener.onScrollStateChanged(view, scrollState);
    }
}
 
源代码6 项目: AutoLoadListView   文件: ZSwipeItem.java
/**
 * if working in {@link android.widget.AdapterView}, we should response
 * {@link android.widget.Adapter} isEnable(int position).
 *
 * @return true when item is enabled, else disabled.
 */
private boolean isEnabledInAdapterView() {
	@SuppressWarnings("rawtypes")
	AdapterView adapterView = getAdapterView();
	boolean enable = true;
	if (adapterView != null) {
		Adapter adapter = adapterView.getAdapter();
		if (adapter != null) {
			int p = adapterView.getPositionForView(ZSwipeItem.this);
			if (adapter instanceof BaseAdapter) {
				enable = ((BaseAdapter) adapter).isEnabled(p);
			} else if (adapter instanceof ListAdapter) {
				enable = ((ListAdapter) adapter).isEnabled(p);
			}
		}
	}
	return enable;
}
 
源代码7 项目: PinyinSearchLibrary   文件: T9SearchFragment.java
private void refreshT9SearchGv() {
	if (null == mT9SearchGv) {
		return;
	}

	BaseAdapter baseAdapter = (BaseAdapter) mT9SearchGv.getAdapter();
	Log.i(TAG, "getCount"+baseAdapter.getCount()+"");
	if (null != baseAdapter) {
		baseAdapter.notifyDataSetChanged();
		if (baseAdapter.getCount() > 0) {
			ViewUtil.showView(mT9SearchGv);
			ViewUtil.hideView(mSearchResultPromptTv);
		} else {
			ViewUtil.hideView(mT9SearchGv);
			ViewUtil.showView(mSearchResultPromptTv);
		}
	}
}
 
源代码8 项目: BigApp_Discuz_Android   文件: RefreshListView.java
public void setAdapter(BaseAdapter adapter) {
    super.setAdapter(adapter);
    mAdapter = (IRefreshAndEditableAdapter) adapter;
    setEditable(isEditable);
    if (autoRefresh) {
        refresh();
    }
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.emotion_gird, container, false);
    BaseAdapter adapter = new XiHaHouEmojiAdapter(mContext);
    GridView grid = (GridView) view.findViewById(R.id.grid);
    grid.setAdapter(adapter);
    grid.setOnItemClickListener(GlobalOnItemClickManager.getInstance().getOnItemClickListener(1));
    return view;
}
 
public static void doFavorite(final Activity activity, final Status s,
        final BaseAdapter adapter) {
    final ActionResultHandler li = new ActionResultHandler() {
        @Override
        public void onActionSuccess(final int type, final String message) {
            if (type == Constants.TYPE_FAVORITES_CREATE) {
                s.favorited = true;
            } else {
                s.favorited = false;
            }
            adapter.notifyDataSetChanged();
        }
    };
    FanfouServiceManager.doFavorite(activity, s, li);
}
 
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}
 
源代码12 项目: StickyNavigationBar   文件: NavBean.java
public NavBean(@TYPE int type, BaseAdapter adapter) {
    this.type = type;
    this.adapter = adapter;
    switch (type) {
        case TYPE_REPOST:
            title = "转发";
            break;
        case TYPE_COMMENT:
            title = "评论";
            break;
        case TYPE_LIKE:
            title = "赞";
            break;
    }
}
 
源代码13 项目: UltimateAndroid   文件: AnimateAdditionAdapter.java
/**
 * Create a new {@link com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateAdditionAdapter} with given {@link android.widget.BaseAdapter}.
 *
 * @param baseAdapter should implement {@link com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateAdditionAdapter.Insertable},
 *                    or be a {@link com.marshalchen.common.uimodule.listviewanimations.BaseAdapterDecorator} whose BaseAdapter implements the interface.
 */
public AnimateAdditionAdapter(final BaseAdapter baseAdapter) {
    super(baseAdapter);

    BaseAdapter rootAdapter = getRootAdapter();
    if (!(rootAdapter instanceof Insertable)) {
        throw new IllegalArgumentException("BaseAdapter should implement Insertable!");
    }

    mInsertable = (Insertable<T>) rootAdapter;
    mInsertQueue = new InsertQueue<T>(mInsertable);
}
 
public BaseAdapter loadProjectMetaEditor(Context context, Document doc) {

        String title = doc.getElementsByTagName(ComprehensionMetaModel.TITLE_TAG).item(0).getTextContent();
        String passage = doc.getElementsByTagName(ComprehensionMetaModel.PASSAGE_TAG).item(0).getTextContent();
        long timer = Long.parseLong(doc.getElementsByTagName(ComprehensionMetaModel.TIMER_TAG).item(0).getTextContent());
        metaData.add(new ComprehensionMetaModel(title, passage, timer));
        metaAdapter = new ComprehensionMetaAdapter(context, metaData);
        setEmptyView((Activity) context);

        return metaAdapter;

    }
 
源代码15 项目: SmartChart   文件: PanelListAdapter.java
/**
 * 返回纵向表头的适配器
 *
 * @return adapter of column ListView
 */
private BaseAdapter getColumnAdapter() {
    if (columnAdapter == null) {
        columnAdapter = new ColumnAdapter(context, android.R.layout.simple_list_item_1, getColumnDataList());
    }
    return columnAdapter;
}
 
源代码16 项目: writeily-pro   文件: WriteilySingleton.java
public void copySelectedNotes(SparseBooleanArray checkedIndices, BaseAdapter notesAdapter, String destination) {
    for (int i = 0; i < checkedIndices.size(); i++) {
        if (checkedIndices.valueAt(i)) {
            File file = (File) notesAdapter.getItem(checkedIndices.keyAt(i));
            copyFile(file, destination);
        }
    }
}
 
源代码17 项目: nono-android   文件: EaseChatRow.java
public EaseChatRow(Context context, EMMessage message, int position, BaseAdapter adapter) {
    super(context);
    this.context = context;
    this.activity = (Activity) context;
    this.message = message;
    this.position = position;
    this.adapter = adapter;
    inflater = LayoutInflater.from(context);

    initView();
}
 
源代码18 项目: school_shop   文件: VoicePlayClickListener.java
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}
 
源代码19 项目: tagcloud   文件: TagCloudLayout.java
public void setAdapter(BaseAdapter adapter){
    if (mAdapter == null){
        mAdapter = adapter;
        if (mObserver == null){
            mObserver = new DataChangeObserver();
            mAdapter.registerDataSetObserver(mObserver);
        }
        drawLayout();
    }
}
 
源代码20 项目: talkback   文件: SwitchAccessPreferenceActivity.java
private void adjustAutoscanPrefs() {
  PreferenceScreen autoScanScreen =
      (PreferenceScreen) findPreference(R.string.pref_category_auto_scan_key);
  PreferenceCategory movementAndSelectionCategory = getMovementAndSelectionCategory();
  Preference autoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_auto_scan_key));
  Preference reverseAutoScanKeyPreference =
      movementAndSelectionCategory.findPreference(
          getString(R.string.pref_key_mapped_to_reverse_auto_scan_key));

  boolean isAutoScanEnabled = SwitchAccessPreferenceUtils.isAutoScanEnabled(getActivity());
  if (isAutoScanEnabled) {
    autoScanScreen.setSummary(R.string.preference_on);
    autoScanKeyPreference.setTitle(R.string.title_pref_category_auto_scan);
    reverseAutoScanKeyPreference.setTitle(R.string.action_name_reverse_auto_scan);

    if (FeatureFlags.groupSelectionWithAutoScan()) {
      return;
    }

    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())) {
      /* If somehow both autoscan and group selection are enabled, turn off group selection. */
      SwitchAccessPreferenceUtils.setScanningMethod(
          getActivity(), R.string.row_col_scanning_key);
    }
  } else {
    autoScanScreen.setSummary(R.string.preference_off);
    autoScanKeyPreference.setTitle(R.string.title_pref_auto_scan_disabled);
    reverseAutoScanKeyPreference.setTitle(R.string.title_pref_reverse_auto_scan_disabled);
    if (SwitchAccessPreferenceUtils.isGroupSelectionEnabled(getActivity())
        && !FeatureFlags.groupSelectionWithAutoScan()) {
      findPreference(R.string.pref_category_auto_scan_key).setEnabled(false);
    }
  }
  ((BaseAdapter) autoScanScreen.getRootAdapter()).notifyDataSetChanged();
  ScanningMethodPreference scanMethodsPref = getScanningMethodPreference();
  scanMethodsPref.enableScanningMethod(R.string.group_selection_key, !isAutoScanEnabled);
}
 
源代码21 项目: APlayer   文件: ColorChooserDialog.java
private void invalidate() {
  if (mGrid.getAdapter() == null) {
    mGrid.setAdapter(new ColorGridAdapter());
    mGrid.setSelector(
        ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
  } else {
    ((BaseAdapter) mGrid.getAdapter()).notifyDataSetChanged();
  }
  if (getDialog() != null) {
    getDialog().setTitle(getTitle());
  }
}
 
源代码22 项目: NetKnight   文件: MainApp.java
@Override
public void onLoadAppInfoList(BaseAdapter adapter) {
    Log.d("MainApp", "加载数据咯");
    app_listView.setAdapter(adapter);

    adapter.notifyDataSetChanged();
}
 
源代码23 项目: GifAssistant   文件: ListContextMenuListener.java
public ListContextMenuListener(Context context, BaseAdapter adapter, int fileType) {
	mContext = context;
	mAdapter = adapter;
	mFileType = fileType;
	mCallBack = null;
	mResideMenu = null;
}
 
源代码24 项目: monolog-android   文件: EaseChatRow.java
public EaseChatRow(Context context, EMMessage message, int position, BaseAdapter adapter) {
    super(context);
    this.context = context;
    this.activity = (Activity) context;
    this.message = message;
    this.position = position;
    this.adapter = adapter;
    inflater = LayoutInflater.from(context);

    initView();
}
 
源代码25 项目: AndroidStudyDemo   文件: CustomListView.java
/**
 * 主要更新一下刷新时间啦!
 * @param adapter
 * @date 2013-11-20 下午5:35:51
 * @change JohnWatson
 * @version 1.0
 */
public void setAdapter(BaseAdapter adapter) {
	// 最近更新: Time
	mLastUpdatedTextView.setText(
			getResources().getString(R.string.p2refresh_refresh_lasttime) + 
			new SimpleDateFormat(DATE_FORMAT_STR, Locale.CHINA).format(new Date()));
	super.setAdapter(adapter);
}
 
源代码26 项目: FimiX8-RE   文件: AdapterWrapper.java
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    return ((BaseAdapter) this.mDelegate).getDropDownView(position, convertView, parent);
}
 
源代码27 项目: FimiX8-RE   文件: AdapterWrapper.java
public void notifyDataSetInvalidated() {
    ((BaseAdapter) this.mDelegate).notifyDataSetInvalidated();
}
 
源代码28 项目: BuildmLearn-Toolkit-Android   文件: InfoTemplate.java
@Override
public BaseAdapter currentTemplateEditorAdapter() {
    return adapter;
}
 
源代码29 项目: Contacts   文件: AnimatedContactAdapter.java
public AnimatedContactAdapter(BaseAdapter baseAdapter, float scaleFrom)
{
	super(baseAdapter, scaleFrom);
}
 
源代码30 项目: HPlayer   文件: ScaleInAnimationAdapter.java
public ScaleInAnimationAdapter(final BaseAdapter baseAdapter, final float scaleFrom) {
    this(baseAdapter, scaleFrom, DEFAULTANIMATIONDELAYMILLIS, DEFAULTANIMATIONDURATIONMILLIS);
}
 
 类所在包
 同包方法