Search in sources :

Example 51 with BaseAdapter

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();
}
Also used : DatabaseHandler(com.se491.chef_ly.Databases.DatabaseHandler) BaseAdapter(android.widget.BaseAdapter)

Example 52 with BaseAdapter

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());
                }
            }
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) Node(org.mazhuang.guanggoo.data.entity.Node) GridView(android.widget.GridView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) NodeCategory(org.mazhuang.guanggoo.data.entity.NodeCategory) AdapterView(android.widget.AdapterView) BaseAdapter(android.widget.BaseAdapter)

Example 53 with BaseAdapter

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();
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 54 with BaseAdapter

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;
}
Also used : AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) BaseAdapter(android.widget.BaseAdapter) SuppressLint(android.annotation.SuppressLint) ListAdapter(android.widget.ListAdapter)

Example 55 with BaseAdapter

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);
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) WindowManager(android.view.WindowManager) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter)

Aggregations

BaseAdapter (android.widget.BaseAdapter)63 View (android.view.View)30 AdapterView (android.widget.AdapterView)26 ViewGroup (android.view.ViewGroup)22 TextView (android.widget.TextView)21 ListAdapter (android.widget.ListAdapter)16 Adapter (android.widget.Adapter)15 ListView (android.widget.ListView)11 PackageInfoData (dev.ukanth.ufirewall.Api.PackageInfoData)8 RemoteAdapterConnectionCallback (android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback)7 Intent (android.content.Intent)5 LayoutInflater (android.view.LayoutInflater)5 SuppressLint (android.annotation.SuppressLint)4 Context (android.content.Context)4 AbsListView (android.widget.AbsListView)4 GridView (android.widget.GridView)4 ImageView (android.widget.ImageView)4 RecyclerView (android.support.v7.widget.RecyclerView)3 MenuItem (android.view.MenuItem)3 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)3