概述
importandroid.content.Context;importandroid.util.AttributeSet;importandroid.view.View;importandroid.widget.ImageView;importandroid.widget.LinearLayout;importandroid.widget.TextView;importcom.sensu.android.zimaogou.Mode.TravelTagMode;importcom.sensu.android.zimaogou.R;importjava.util.ArrayList;importjava.util.List;/*** Created by qi.yang on 2015/12/23.*/
public class MyTagListView extendsFlowLayout {private List mTravelTagModes = new ArrayList();publicMyTagListView(Context context) {super(context);
}publicMyTagListView(Context context, AttributeSet attributeSet) {super(context, attributeSet);
}public MyTagListView(Context context, AttributeSet attributeSet, intdefStyle) {super(context, attributeSet, defStyle);
}public void setTravelTagModes(List extends TravelTagMode>lists) {
setTravelTagModes(lists,false);
}public void setTravelTagModes(List extends TravelTagMode> lists, booleanb) {
removeAllViews();
mTravelTagModes.clear();for (int i = 0; i < lists.size(); i++) {
addTravelTagMode((TravelTagMode) lists.get(i), b);
}
}public void addTravelTagMode(TravelTagMode travelTagMode, booleanb) {
mTravelTagModes.add(travelTagMode);
inflateTravelTagModeView(travelTagMode, b);
}private void inflateTravelTagModeView(TravelTagMode t, booleanb) {
View localTravelTagModeView=View.inflate(getContext(),
R.layout.travel_tag_list_item,null);final LinearLayout ll_tag =(LinearLayout) localTravelTagModeView.findViewById(R.id.food_layout);final TextView tv_title =(TextView) localTravelTagModeView.findViewById(R.id.food_text);final ImageView img_tag =(ImageView) localTravelTagModeView.findViewById(R.id.food_select);
tv_title.setText(t.getName());
ll_tag.setTag(t);
ll_tag.setOnClickListener(newView.OnClickListener() {
@Overridepublic voidonClick(View view) {
TravelTagMode tagMode=(TravelTagMode) ll_tag.getTag();if(tagMode.isCheck()) {
ll_tag.setSelected(false);
tv_title.setSelected(false);
img_tag.setVisibility(View.GONE);
tagMode.setCheck(!tagMode.isCheck());
}else{
ll_tag.setSelected(true);
tv_title.setSelected(true);
img_tag.setVisibility(View.VISIBLE);
tagMode.setCheck(!tagMode.isCheck());
}
}
});
addView(localTravelTagModeView);
}
}
最后
以上就是伶俐帅哥为你收集整理的android 标签view,android 标签view的全部内容,希望文章能够帮你解决android 标签view,android 标签view所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复