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 9169057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:46:50+00:00 2026-06-17T15:46:50+00:00

i build an adapter for a listview_item which contains image, textview and textbox, i

  • 0

i build an adapter for a listview_item which contains image, textview and textbox, i don’t know why the application throw an exception,

class RestaurantAdapter extends BaseAdapter {
    private static LayoutInflater inflater = null;
    private ArrayList<HashMap<String, String>> data;
    Activity activity;

    public RestaurantAdapter(Activity activity,
            ArrayList<HashMap<String, String>> data) {
        // TODO Auto-generated constructor stub
        this.activity = activity;
        this.data = data;
        inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        View vi = convertView;
        if (vi == null)
            inflater.inflate(R.layout.restaurant_multi_select_list_item, null);
         TextView name = (TextView) vi
                .findViewById(R.id.restaurant_multi_select_title);
        ImageView image = (ImageView) vi
                .findViewById(R.id.restaurant_multi_select_list_item_image);
        CheckBox cb = (CheckBox) vi
                .findViewById(R.id.restaurant_multi_select_checkBox);
        HashMap<String, String> restaurant = data.get(position);
        name.setText(restaurant.get("name"));
        cb.setSelected(false);
        image.setId(Integer.parseInt(restaurant.get("image")));
        return vi;

    }
}

when i made the getview contains just this code

View vi = convertView;
            if (vi == null)
                inflater.inflate(R.layout.restaurant_multi_select_list_item, null);

it still throws the exception

if you want any another code i will give it to you

thanks

edit

exception

01-23 19:45:27.021: E/AndroidRuntime(24106): FATAL EXCEPTION: main
01-23 19:45:27.021: E/AndroidRuntime(24106): java.lang.NullPointerException
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.AbsListView.obtainView(AbsListView.java:1521)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.ListView.makeAndAddView(ListView.java:1749)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.ListView.fillDown(ListView.java:674)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.ListView.fillFromTop(ListView.java:731)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.ListView.layoutChildren(ListView.java:1602)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.AbsListView.onLayout(AbsListView.java:1349)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.View.layout(View.java:7320)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1263)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1137)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1051)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.View.layout(View.java:7320)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.FrameLayout.onLayout(FrameLayout.java:342)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.View.layout(View.java:7320)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1263)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1137)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1051)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.View.layout(View.java:7320)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.widget.FrameLayout.onLayout(FrameLayout.java:342)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.View.layout(View.java:7320)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.ViewRoot.performTraversals(ViewRoot.java:1162)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1882)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.os.Looper.loop(Looper.java:130)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at android.app.ActivityThread.main(ActivityThread.java:3701)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at java.lang.reflect.Method.invokeNative(Native Method)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at java.lang.reflect.Method.invoke(Method.java:507)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
01-23 19:45:27.021: E/AndroidRuntime(24106):    at dalvik.system.NativeStart.main(Native Method)

the new exception

01-22 12:36:37.994: E/AndroidRuntime(318): FATAL EXCEPTION: main
01-22 12:36:37.994: E/AndroidRuntime(318): java.lang.NullPointerException
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.eattel.syriatel.RestaurantAdapter.getView(Select_Multi_Restaurants.java:113)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.AbsListView.obtainView(AbsListView.java:1294)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.ListView.makeAndAddView(ListView.java:1727)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.ListView.fillDown(ListView.java:652)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.ListView.fillGap(ListView.java:623)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.AbsListView.onTouchEvent(AbsListView.java:2065)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.widget.ListView.onTouchEvent(ListView.java:3315)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.View.dispatchTouchEvent(View.java:3766)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.os.Looper.loop(Looper.java:123)
01-22 12:36:37.994: E/AndroidRuntime(318):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-22 12:36:37.994: E/AndroidRuntime(318):  at java.lang.reflect.Method.invokeNative(Native Method)
01-22 12:36:37.994: E/AndroidRuntime(318):  at java.lang.reflect.Method.invoke(Method.java:521)
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-22 12:36:37.994: E/AndroidRuntime(318):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-22 12:36:37.994: E/AndroidRuntime(318):  at dalvik.system.NativeStart.main(Native Method)
  • 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-06-17T15:46:53+00:00Added an answer on June 17, 2026 at 3:46 pm

    if vi == null then you have to set the inflater to vi. otherwise you are trying to get a view from nothing or null

    for example

    if (vi == null)
           vi = inflater.inflate(R.layout.restaurant_multi_select_list_item, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have build an android application which has a main menu. In the main
Build a menu using the WPF Ribbon. My application is in the MVVM pattern.
My build target is set for IOS5 which is where I understand UIButton.tintColor was
I build a Web Service in ASP.Net which sends me a list of rooms.
I am trying to build an application that converts my old custom Ethernet logs
I am trying to use array adapter to populate my listview. I build an
i build application who take all the files in my ListView (pcap files )and
We use the built in table adapter wizard in VS2005 to build a portion
Different Adapter Lists Returned I would like to know the root cause of why
I am trying to build a custom adapter for my app, who's main screen

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.