0
public View getView(int position, View convertview, ViewGroup parentview){
View listItemview=convertview;
if(listItemview==null)  {listItemview = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parentview, false); }

Books currentbook =getItem(position);

TextView titleTextView =  listItemview.findViewById(R.id.bookName);
if (currentbook != null) {
    titleTextView.setText(currentbook.getmTitle());
}

TextView pageTextView = listItemview.findViewById(pages);
if (currentbook != null) {
    pageTextView.setText( currentbook.getmPageCount());
}

return listItemview;

Exception throwed at this line...titleTextView.setText(currentbook.getmTitle()); also attached the getmTitle method. this is a program where an url is taken and a JSONresponse from url is extracted and parsed and dispalyaed.

  public Books(String vTitle, ArrayList<String> vAuthorName, int vPageCount, String vUrl)
{
   mTitle=vTitle;
   mAuthorName=vAuthorName;
   mPageCount=vPageCount;
    mUrl= vUrl;

}


public String getmTitle(){return mTitle; }
public ArrayList<String>getmAuthorName(){return mAuthorName;}
public int getmPageCount() { return mPageCount; }
public String getmUrl() { return mUrl;}

}

  • I'm pretty sure you're looking at the wrong line. That Exception will be thrown on `pageTextView.setText( currentbook.getmPageCount());`, not `titleTextView.setText(currentbook.getmTitle());`. You cannot call `setText()` with an arbitrary integer value. You'll need to convert it to a `String` first; e.g., `pageTextView.setText(String.valueOf(currentbook.getmPageCount()));`. – Mike M. Jun 28 '20 at 06:30
  • 1
    Oh...ya got it..thanks..silly – satish mms Jun 29 '20 at 07:14

0 Answers0