java - How to extends ArrayAdapter to print Parsed JSON? -


i have tried , read many answers can't able figure out how code...

newsadapter.java

public class newsadapter extends arrayadapter{     private static final string debug_tag = "newsadapter";     private layoutinflater inflater;      public newsadapter(activity activity, arraylist<string> items){         super(activity, r.layout.news_feed, items);         log.d(debug_tag, "this came world know of" + items);         inflater = activity.getwindow().getlayoutinflater();     }      @override     public view getview(int position, view convertview, viewgroup parent){         return inflater.inflate(r.layout.news_feed, parent, false);     } } 

news_feed.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent" android:layout_height="match_parent">      <textview android:id="@+id/title"         android:text="@string/news_title"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:textsize="19sp" />  </linearlayout> 

and output of above code ...

enter image description here

how items value , how settext ?

do this:

public class newsadapter extends arrayadapter{     private static final string debug_tag = "newsadapter";     private layoutinflater inflater;     arraylist<string> items;      public newsadapter(activity activity, arraylist<string> items){          inflater = activity.getwindow().getlayoutinflater();         this.items = items;     }      @override     public view getview(int position, view convertview, viewgroup parent){         view v = convertview         if(v == null)             v = inflater.inflate(r.layout.news_feed, parent, false);         textview txttitle = (textview) v.findviewbyid(r.id.title);         txttitle.settext(items.get(position));         return v;     } } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -