use of com.vondear.rxtools.model.ActionItem in project RxTools by vondear.
the class RxPopupSingleView method populateActions.
/**
* 设置弹窗列表子项
*/
private void populateActions() {
mIsDirty = false;
// 设置列表的适配器
mListView.setAdapter(new BaseAdapter() {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv_itpop = null;
ImageView iv_itpop = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_listview_popup, null);
}
tv_itpop = (TextView) convertView.findViewById(R.id.tv_itpop);
iv_itpop = (ImageView) convertView.findViewById(R.id.iv_itpop);
if (colorItemText == 0) {
colorItemText = mContext.getResources().getColor(android.R.color.white);
}
tv_itpop.setTextColor(colorItemText);
tv_itpop.setTextSize(14);
// 设置文本居中
tv_itpop.setGravity(Gravity.CENTER);
// 设置文本域的范围
tv_itpop.setPadding(0, 10, 0, 10);
// 设置文本在一行内显示(不换行)
tv_itpop.setSingleLine(true);
ActionItem item = mActionItems.get(position);
// 设置文本文字
tv_itpop.setText(item.mTitle);
if (item.mResourcesId == 0) {
iv_itpop.setVisibility(View.GONE);
} else {
iv_itpop.setVisibility(View.VISIBLE);
iv_itpop.setImageResource(item.mResourcesId);
}
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 com.vondear.rxtools.model.ActionItem in project RxTools by vondear.
the class ActivityPopupView method initPopupView.
private void initPopupView() {
titlePopup = new RxPopupSingleView(mContext, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, R.layout.popupwindow_definition_layout);
titlePopup.addAction(new ActionItem("标清"));
titlePopup.addAction(new ActionItem("高清"));
titlePopup.addAction(new ActionItem("超清"));
titlePopup.setItemOnClickListener(new RxPopupSingleView.OnItemOnClickListener() {
@Override
public void onItemClick(ActionItem item, int position) {
// TODO Auto-generated method stub
if (titlePopup.getAction(position).mTitle.equals(mTvDefinition.getText())) {
RxToast.showToast(mContext, "当前已经为" + mTvDefinition.getText(), 500);
} else {
if (position >= 0 && position < 3) {
mTvDefinition.setText(titlePopup.getAction(position).mTitle);
}
}
}
});
}
Aggregations