Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:09:38+00:00 2026-05-14T15:09:38+00:00

I am trying to create a list view which as TextView that can display

  • 0

I am trying to create a list view which as TextView that can display html content , an WebView and other basic TextViews.I tried to extend SimpleAdapter but i struck with the problem ,I will be glad if someone can point out the mistake i am doing.

In onCreate method

 ArrayList<HashMap<String, String>> mylist= resultfromXmlparser();

 adap = new MyAdapter(TourLandingPage.this, mylist, R.layout.row,
            new String[] {"Name", "desc","Duration","Price","imgurl"},  new int[]
            {R.id.productname,R.id.des,R.id.duration,R.id.pricefrom,R.id.photo});

setListAdapter(adap);


My custom Adapter looks like this

 private class MyAdapter extends SimpleAdapter {

             ArrayList<HashMap<String,String>> elements;
             Context ctx;
             public MyAdapter(Context context, ArrayList<HashMap<String,String>> mylist,int textViewResourceId,String[] names,int[] resouceid) {
             super(context, mylist,textViewResourceId, names,resouceid);
             this.elements=mylist;
             this.ctx=context;

             }
             @Override
             public int getCount() {
                  return elements.size();
                 }
             @Override
             public Object getItem(int position) {
                  return elements.get(position);
              }
            @Override
            public long getItemId(int position) {
                  return position;
                 }


                  @Override
           public View getView(int position, View convertView, ViewGroup parent) {
             RelativeLayout rowLayout;
                    if (convertView == null) {
                     rowLayout = (RelativeLayout) 
                         LayoutInflater.from(ctx).inflate(R.layout.rowfor_tourlist, parent, false);

               } else {

                rowLayout = (RelativeLayout) convertView;
                     }


                  TextView in = (TextView)rowLayout.findViewById(R.id.introduction);
                  TextView du = (TextView)rowLayout.findViewById(R.id.duration);
                  TextView pf = (TextView)rowLayout.findViewById(R.id.pricefrom);
                  TextView pn = (TextView)rowLayout.findViewById(R.id.productname);
                  WebView wv=(WebView)rowLayout.findViewById(R.id.photo);  
                  in.setText(Html.fromHtml(mylist.get(position).get("desc")));
                  du.setText(mylist.get(position).get("Duration"));
                  pf.setText(mylist.get(position).get("Price"));
                  pn.setText(mylist.get(position).get("Name"));
                  wv.getSettings().setJavaScriptEnabled(true);
                  wv.loadUrl(mylist.get(position).get("imgurl"));


                 return convertView;
             }         
         }//class

and my row.xml file looks like

  RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"

  TextView 
       android:id="@+id/productname"
       ......

  LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="60dip"
         android:layout_margin="5dip"
         android:layout_below="@id/productname"
         android:orientation="horizontal"
         android:id="@+id/lay1"

         WebView 
          android:id="@+id/photo"
          ....
         TextView 
           android:id="@+id/introduction"
           ......
   LinearLayout

   TextView 
      android:id="@+id/duration" 
      ....
   TextView 
     android:id="@+id/pricefrom" 
      ..... 

RelativeLayout

The error i was getting was

04-28 19:46:17.749: ERROR/AndroidRuntime(976): Uncaught handler: thread main exiting due to uncaught exception
04-28 19:46:17.769: ERROR/AndroidRuntime(976): java.lang.NullPointerException
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.ListView.setupChild(ListView.java:1693)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.ListView.makeAndAddView(ListView.java:1671)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.ListView.fillDown(ListView.java:637)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.ListView.fillFromTop(ListView.java:694)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.ListView.layoutChildren(ListView.java:1521)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.AbsListView.onLayout(AbsListView.java:1113)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1108)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.onLayout(LinearLayout.java:920)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.View.layout(View.java:6831)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.ViewRoot.performTraversals(ViewRoot.java:996)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.os.Looper.loop(Looper.java:123)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at android.app.ActivityThread.main(ActivityThread.java:4338)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at java.lang.reflect.Method.invokeNative(Native Method)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at java.lang.reflect.Method.invoke(Method.java:521)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-28 19:46:17.769: ERROR/AndroidRuntime(976):     at dalvik.system.NativeStart.main(Native Method)
04-28 19:46:17.789: INFO/Process(52): Sending signal. PID: 976 SIG: 3
04-28 19:46:17.799: INFO/dalvikvm(976): threadid=7: reacting to signal 3
04-28 19:46:17.829: INFO/dalvikvm(976): Wrote stack trace to '/data/anr/traces.txt'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:09:39+00:00Added an answer on May 14, 2026 at 3:09 pm

    Not sure if this is the cause but the last parameter to the SimpleAdapter constructor should all be TextViews.

    SimpleAdapter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.