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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:47+00:00 2026-05-25T14:40:47+00:00

I have a donorview class which extends linearlayout which is as follows: public class

  • 0

I have a donorview class which extends linearlayout which is as follows:

public class donorview extends LinearLayout {
private TextView donortext;
private String donorstr;
private ImageButton call;
private ImageButton msg;
private String donornumber;
private Context context1;
private View convertView;

public donorview(Context context, String donorname1, String donornum) {
    super(context);
    context1 = context;
    // TODO Auto-generated constructor stub
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.listformat, null);
    convertView.setClickable(true);
    donortext = (TextView) findViewById(R.id.donornametext);
    call = (ImageButton) findViewById(R.id.call);
    msg = (ImageButton) findViewById(R.id.msg);
    System.out.println("donorname:"+donorname1);
    System.out.println("donornum:"+donornum);
    donortext.setText(donorname1);
    System.out.println("after setting text");
    donorstr = donorname1;
    donornumber = donornum;
}

void onClickCall(){
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse("tel:" + donornumber));
      convertView.getContext().startActivity(callIntent);
}
public void setdonorname(String donorname12) {
    donortext.setText(donorname12);
}

public String getdonorname() {
    return this.donorstr;
}
}

I get a NullPoinerException as

java.lang.NullPonintereException
at com.wglxy.example.dash1.donorview.<init>(donorview.java:35)

while setting the text of the textview donortext. My XML layout of the listformat is

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/linerlayout1"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView android:id="@+id/donornametext" android:layout_height="wrap_content"
        android:layout_width="wrap_content"  android:layout_weight="1" android:text="a"/>

    <ImageButton android:layout_width="wrap_content" android:id="@+id/call"
        android:layout_height="wrap_content" android:contentDescription="@string/description_about"
        android:src="@drawable/call" android:onClick="onClickCall"
        android:background="#ffffff" />
    <ImageButton android:layout_width="wrap_content" android:id="@+id/msg"
        android:layout_height="wrap_content" android:contentDescription="@string/description_about"
        android:src="@drawable/msg" android:onClick="onClickMsg"
        android:background="#ffffff" />

</LinearLayout>

I dont understand what I am doing wrong. The list that is being displayed is empty. When i am printing the donorname and donornum it is being printed but the custom list displayed is empty.I have been trying to figure it out from a long time. Could anyone please help me with this?
My adapter code is as follows

   public class donorAdapter extends BaseAdapter {

private Activity activity;

ArrayList<String> names = new ArrayList<String>();
ArrayList<String> nums = new ArrayList<String>();
private Context context;

private String strnum;

private String strname;
private static LayoutInflater inflater = null;


public donorAdapter(Context context, Activity a, ArrayList<String> names,
        ArrayList<String> nums) {
    this.context = context;
    activity = a;
    this.names = names;
    this.nums = nums;
    inflater = LayoutInflater.from(activity);
}

public int getCount() {
    return names.size();
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    donorview fv;
    if (convertView == null) {
        System.out.println("inside getview:"+names.get(position).toString());
        strname=names.get(position).toString();
        strnum=nums.get(position).toString();
        System.out.println("inside getview:"+nums.get(position).toString());
        fv = new donorview(context, strname,strnum);
        convertView = fv;
    }
    else {
        ((donorview) convertView).setdonorname(names.get(position)
                .toString());
    }
    convertView.setClickable(true);
    convertView.setFocusable(true);
    return convertView;
}

}

-Thanks in advance

  • 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-25T14:40:47+00:00Added an answer on May 25, 2026 at 2:40 pm

    You should use

    donortext = (TextView)convertView.findViewById(R.id.donornametext);
    

    and also replace your code by

    convertView = inflater.inflate(R.layout.listformat, this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have next code: class GameTexture { private: LPDIRECT3DTEXTURE9 texture; unsigned char *alphaLayer; UINT width,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have a xml string, goal is to replace an xml element value to a
have an an array String classname[]={'a','b','c','d'}; ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>( getApplicationContext(), R.layout.spinner_item_class, R.id.spinnerclasstxt,
Have anyone used Redmine Documentor which lets you convert PHP to HTML to Redmine
Have the following scenario. I have a few form, which essentially have a few
Have a bunch of classes which I need to do serialize and deserialize from/to
Have you ever tried working with a XAML file which contains thousand tons of
Have this method call: -> simpleJdbcTemplate.queryForInt(SQL,null); -> queryForInt() method in the springs SimpleJdbcTemplate throws
Have just started using Google Chrome , and noticed in parts of our site,

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.