java - ListView item is not clicking -


i have fragment listview. problem listviewitem having web-html links. not clickable. @drawable/items_selector not working , onitemclick not call when android:autolink="web" "android:descendantfocusability="blocksdescendants" not helped. , this solution not works. need listview item "hangouts" or other apps whith work item selected , working html links , etc. please me. os version android 5.1.1

enter image description here

simple xml... not works too.

 <linearlayout   xmlns:android="http://schemas.android.com/apk/res/android"   android:descendantfocusability="blocksdescendants"    android:layout_width="match_parent"   android:layout_height="wrap_content"   android:background="@drawable/items_selector"   android:orientation="vertical"   android:padding="2dp">  <textview     android:id="@+id/themetext"     android:autolink="web"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:paddingbottom="@dimen/layout_margin"     android:paddingleft="@dimen/layout_margin"     android:paddingright="@dimen/layout_margin"     android:text="bla bla bla"/>  </linearlayout> 

adapter code:

 private class themesadapter extends baseadapter {     private layoutinflater layoutinflater;     private arraylist<forumthemeitem> mthemes;      public themesadapter(context context, arraylist<forumthemeitem> themes) {         this.mthemes = themes;         layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);     }      public int getcount() {         if (mthemes != null) {             return mthemes.size();         }         return 0;     }      public void add(arraylist<forumthemeitem> themes){         mthemes.addall(themes);     }      public forumthemeitem getitem(int position) {         return mthemes.get(position);     }      public long getitemid(int position) {         return position;     }      public view getview(int position, view convertview, viewgroup parent) {         forumthemeitem mtheme = getitem(position);         themesviewholder viewholder;          if (convertview == null) {             viewholder = new themesviewholder();             convertview = layoutinflater.inflate(r.layout.item_theme, null);             convertview.findviewbyid(r.id.ratinglayout).setvisibility(view.gone);             viewholder.themepart = (textview)convertview.findviewbyid(r.id.themepart);             viewholder.themetext = (textview)convertview.findviewbyid(r.id.themetext);             viewholder.themedate = (textview)convertview.findviewbyid(r.id.themedate);             viewholder.themedateupdate = (textview)convertview.findviewbyid(r.id.themedateupdate);             viewholder.usernick = (textview)convertview.findviewbyid(r.id.usernick);             viewholder.vote = (imageview)convertview.findviewbyid(r.id.vote);             viewholder.viewscount =(textview)convertview.findviewbyid(r.id.viewscount);             viewholder.replycount =(textview)convertview.findviewbyid(r.id.replycount);             convertview.settag(viewholder);         }else{             viewholder = (themesviewholder) convertview.gettag();         }           viewholder.vote.setvisibility(mtheme.isvote() ? view.visible : view.gone);         viewholder.themetext.settext(html.fromhtml(mtheme.gettext()));         viewholder.usernick.settext(mtheme.getnick());         viewholder.themedate.settext(mtheme.getcreatedate()+",");         viewholder.themedateupdate.settext(string.format("обн.: %s",mtheme.getdateupdate()));         viewholder.viewscount.settext(string.format("%s",mtheme.getviewscount()));         viewholder.replycount.settext(string.format("%s", mtheme.getrepliescount()));          if(mtheme.getpartsubname()==null){             viewholder.themepart.settext(mtheme.getpartname());         }else{             viewholder.themepart.settext(string.format("%s (%s)",mtheme.getpartname(),mtheme.getpartsubname()));         }          if(!mtheme.isanonymously()){             switch (mtheme.getgender()){                 case "f":                     viewholder.usernick.settextcolor(getresources().getcolor(r.color.woman));                     break;                 case "m":                     viewholder.usernick.settextcolor(getresources().getcolor(r.color.man));                     break;                 case "n":                     viewholder.usernick.settextcolor(getresources().getcolor(r.color.it));                     break;             }         }else{             viewholder.usernick.settextcolor(getresources().getcolor(r.color.default_text_color));         }          return convertview;     }      class themesviewholder {         textview themepart;         textview themedate;         textview themedateupdate;         textview themetext;         textview usernick;         imageview vote;         textview viewscount;         textview replycount;     } } 

i modify adapter.

in adapter:

  viewholder.themetext.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 if(mtextclicklistener!=null){                     mtextclicklistener.ontextclick(position);                 }             }         }); 

in activity:

@override public void ontextclick(int position) {     mthemeslist.performitemclick(mthemeslist.getadapter().getview(position, null, null), position, position); } 

but item not selected(no fill gray)

enter image description here

if want click entire row, implement onclicklistener.

if want click entire row , links inside row (which thing want):

  • you have create custom row item
  • create interface
  • send interface listener adapter
  • check if text contains link. if use listener send link

something this:

interface onweblinkclick(){     void onweblinkclick(string url); } 

on adapter add parameter onweblinclick listener:

public themesadapter(context context, arraylist<forumthemeitem> themes, onweblinclick mlistener){    this.mlistener = mlistener;    }  

check if text contains link , implement onweblinkclick(urlontextview) , open in webview


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -