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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:21:19+00:00 2026-06-14T21:21:19+00:00

I’m using Parse.com server and i’m trying to get data from the server and

  • 0

I’m using Parse.com server and i’m trying to get data from the server and put it in a custom list that has 4 field of TextView. I received the data well but I have a problem in the adapter in the first position of the list i get null pointer exception on all the textView fields. in the rest of the fields there is no problem.

this is the code I’m using:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_coupon_list);

    init(); 
}

private void init(){
    couponListView = (ListView)findViewById(android.R.id.list);
    couponList = new ArrayList<ParseObject>();
    query = new ParseQuery(COUPON_CLASS_NAME);

    couponListView.setOnItemClickListener(this);

    query.findInBackground(new FindCallback() {             
        @Override
        public void done(List<ParseObject> list, ParseException e) {
            if (e == null) { //objects retrieved well                                                           
                couponList.addAll(list);                                                        
            }
            else {
                toaster("problem find coupons");
            }

            MyAdapter adapter = new MyAdapter(
                    getApplicationContext(), 
                    android.R.layout.simple_list_item_1, 
                    R.id.tv_coupoun_content,
                    couponList);

            setListAdapter(adapter);

        }
    });                     
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_coupon_list, menu);
    return true;
}   

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {}

public class MyAdapter extends ArrayAdapter<ParseObject> {

    public MyAdapter(Context context, int resource, int textViewResourceId, ArrayList<ParseObject> couponList) {
        super(context, resource, textViewResourceId, couponList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater lf = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = lf.inflate(R.layout.coupon_row, parent, false);                                     

        tvCouponContent = (TextView)findViewById(R.id.tv_coupoun_content);
        tvBusinessName = (TextView)findViewById(R.id.tv_business_name);
        tvBusinessStreet = (TextView)findViewById(R.id.tv_street);
        tvBusinessCity = (TextView)findViewById(R.id.tv_city);

        //in position 0 the log below is true for all in the rest its false


        Log.d("Shalom","shalom - " + Boolean.toString(tvCouponContent == null)+" "+
                Boolean.toString(tvBusinessName == null)+" "+
                Boolean.toString(tvBusinessStreet == null)+" "+
                Boolean.toString(tvBusinessCity == null)+" "+
                Integer.toString(position));

        /*tvCouponContent.setText(coupons.getString(COUPON_CONTENT));           
        tvBusinessName.setText(coupons.getString(COUPON_BUSINESS_NAME));
        tvBusinessStreet.setText(coupons.getString(COUPON_STREET));
        tvBusinessCity.setText(coupons.getString(COUPON_CITY));*/

        return row;
    }
}
  • 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-14T21:21:22+00:00Added an answer on June 14, 2026 at 9:21 pm

    Your Adapter constructor is wrong, use the following constructor:

    public MyAdapter(Context context, ArrayList<ParseObject> couponList) {
        super(context, R.layout.coupon_row, couponList);
    }
    

    for instantiate it:

    MyAdapter adapter = new MyAdapter(getApplicationContext(),couponList);
    

    for inflate items into a listview you must to use the inflated object:

    View row = lf.inflate(R.layout.coupon_row, parent, false);
    
    tvCouponContent = (TextView)findViewById(R.id.tv_coupoun_content); //BAD
    
    tvCouponContent = (TextView)row.findViewById(R.id.tv_coupoun_content);//GOOD
    

    You should use View Holder pattern: http://www.jmanzano.es/blog/?p=166

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.