use of android.widget.BaseAdapter in project chefly_android by chef-ly.
the class ShoppingListActivity method addText.
private void addText(String text) {
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
db.addItemToShoppingList(text, false);
shoppingList = db.getShoppingList();
((BaseAdapter) getListAdapter()).notifyDataSetChanged();
}
use of android.widget.BaseAdapter in project guanggoo-android by mzlogin.
the class NodesCloudAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(NodesCloudAdapter.ViewHolder holder, int position) {
final NodeCategory category = mData.get(position);
holder.mTitleTextView.setText(category.getLabel());
holder.mNodesGridView.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
return (category.getNodes() == null) ? 0 : category.getNodes().size();
}
@Override
public Object getItem(int position) {
return category.getNodes().get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ChildViewHolder childViewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.child_nodes_cloud, null);
childViewHolder = new ChildViewHolder(convertView);
convertView.setTag(childViewHolder);
} else {
childViewHolder = (ChildViewHolder) convertView.getTag();
}
childViewHolder.mTitleTextView.setText(category.getNodes().get(position).getTitle());
return convertView;
}
});
holder.mNodesGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (mListener != null) {
Node node = category.getNodes().get(position);
if (mNodeClickListener != null) {
mNodeClickListener.onNodeClick(node);
} else {
mListener.openPage(node.getUrl(), node.getTitle());
}
}
}
});
}
use of android.widget.BaseAdapter in project wechat by motianhuo.
the class TitlePopup method populateActions.
/**
* 设置弹窗列表子项
*/
private void populateActions() {
mIsDirty = false;
// 设置列表的适配器
mListView.setAdapter(new BaseAdapter() {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_item_pop, parent, false);
}
TextView textView = ViewHolder.get(convertView, R.id.txt_title);
textView.setTextColor(mContext.getResources().getColor(android.R.color.white));
textView.setTextSize(16);
// 设置文本居中
textView.setGravity(Gravity.CENTER_VERTICAL);
// // 设置文本域的范围
// textView.setPadding(0, 10, 0, 10);
// 设置文本在一行内显示(不换行)
textView.setSingleLine(true);
ActionItem item = mActionItems.get(position);
// 设置文本文字
textView.setText(item.mTitle);
if (item.mDrawable != null) {
// 设置文字与图标的间隔
textView.setCompoundDrawablePadding(10);
// 设置在文字的左边放一个图标
textView.setCompoundDrawablesWithIntrinsicBounds(item.mDrawable, null, null, null);
}
return convertView;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return mActionItems.get(position);
}
@Override
public int getCount() {
return mActionItems.size();
}
});
}
use of android.widget.BaseAdapter in project wechat by motianhuo.
the class SwipeLayout method isEnabledInAdapterView.
/**
* 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() {
AdapterView adapterView = getAdapterView();
boolean enable = true;
if (adapterView != null) {
Adapter adapter = adapterView.getAdapter();
if (adapter != null) {
int p = adapterView.getPositionForView(SwipeLayout.this);
if (adapter instanceof BaseAdapter) {
enable = ((BaseAdapter) adapter).isEnabled(p);
} else if (adapter instanceof ListAdapter) {
enable = ((ListAdapter) adapter).isEnabled(p);
}
}
}
return enable;
}
use of android.widget.BaseAdapter in project NewXmPluginSDK by MiEcosystem.
the class MenuDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setGravity(Gravity.TOP);
TitleBarUtil.enableWhiteTranslucentStatus(getWindow());
try {
XmPluginCommonApi.instance().setMenuDialogWindowAnimations(getWindow());
} catch (Throwable e) {
}
mLayoutInflater = LayoutInflater.from(getContext());
mRootView = mLayoutInflater.inflate(R.layout.menu_dialog, null);
getWindow().setContentView(mRootView);
TitleBarUtil.setTitleBarPadding(getContext().getResources().getDimensionPixelSize(R.dimen.title_bar_top_padding), mRootView);
if (mBackgroundColor > 0) {
mRootView.setBackgroundColor(mBackgroundColor);
}
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.y = 0;
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
getWindow().setAttributes(lp);
setCancelable(true);
setCanceledOnTouchOutside(true);
mListView = (ListView) findViewById(R.id.select_dialog_listview);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (onClickListener != null) {
dismiss();
onClickListener.onClick(null, i);
}
}
});
findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
if (mListViewAdapter == null && mItems != null) {
mListViewAdapter = new BaseAdapter() {
@Override
public int getCount() {
return mItems.length;
}
@Override
public Object getItem(int i) {
return mItems[i];
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = mLayoutInflater.inflate(R.layout.menu_dialog_item, null);
}
TextView textView = (TextView) view.findViewById(R.id.text1);
textView.setText(mItems[i]);
return view;
}
};
}
if (mListViewAdapter != null)
mListView.setAdapter(mListViewAdapter);
}
Aggregations