我已创建和Android应用程序,我想隐藏和使用自定义适配器在ListVIEw中显示视图.
我的代码是:
@OverrIDepublic VIEw getVIEw(final int position, VIEw convertVIEw, VIEwGroup parent){ LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); VIEw vi = convertVIEw; if (convertVIEw == null) { vi = inflater.inflate(R.layout.item_estimate, null); btn_dots = (Imagebutton) vi.findVIEwByID(R.ID.btn_dots_itemEstimate); ll_2 = (linearLayout) vi.findVIEwByID(R.ID.ll_2_itemEstimate); } btn_dots.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw arg0) { if (ll_2.getVisibility() == VIEw.GONE) { ll_2.setVisibility(VIEw.VISIBLE); } else { ll_2.setVisibility(VIEw.GONE); } } }); return vi;}
点击Dots时,它不会隐藏布局.
谢谢.
解决方法:
是的,我遇到了同样的问题并使用ExpandableListVIEw解决了它.我正在粘贴下面的代码
public DefaultContactlistadapter(Context context, ArrayList<Cont> List2) { super(); this.context = context; this.contactList = contactList2; @OverrIDe public Object getChild(int parent, int child) { return child;// return glossarIEsList.get(Sub_List.get(parent) ).get(child); } @OverrIDe public long getChildID(int parent, int child) { // Todo auto-generated method stub return child; } @OverrIDe public VIEw getChildVIEw(int parent, int child, boolean lastChild, VIEw convertvIEw, VIEwGroup parentvIEw) {// String child_Title=(String) getChild(parent, child); if(convertvIEw==null) { LayoutInflater inflator=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertvIEw=inflator.inflate(R.layout.layout_default_contact_screen_child, parentvIEw, false); } return convertvIEw; } @OverrIDe public int getChildrenCount(int groupposition) { return 1; } @OverrIDe public Object getGroup(int groupposition) { // Todo auto-generated method stub return contactList.get(groupposition); } @OverrIDe public int getGroupCount() { // Todo auto-generated method stub return contactList.size(); } @OverrIDe public long getGroupID(int groupposition) { // Todo auto-generated method stub return groupposition; } @OverrIDe public VIEw getGroupVIEw(int parent, boolean isExpanded, VIEw convertVIEw, VIEwGroup parentvIEw) { // Todo auto-generated method stub //String group_Title=(String) getGroup(parent); if(convertVIEw==null) { LayoutInflater inflator=(LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); convertVIEw=inflator.inflate(R.layout.layout_default_screen, parentvIEw,false); } return convertVIEw; } @OverrIDe public boolean hasStableIDs() { // Todo auto-generated method stub return false; } @OverrIDe public boolean isChildSelectable(int groupposition, int childposition) { // Todo auto-generated method stub return false; }}
总结 以上是内存溢出为你收集整理的在ListView Android中隐藏和显示视图全部内容,希望文章能够帮你解决在ListView Android中隐藏和显示视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)