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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:24:54+00:00 2026-06-09T15:24:54+00:00

I’m trying to make a customized ListView, that should display a note title and

  • 0

I’m trying to make a customized ListView, that should display a note title and the time and date the note was created, each in separate TextView, while each Note title also colored by the color value stored in the DB. So I created a custom adapter for it:

public class NoteAdapter extends ArrayAdapter<Note> {

public NoteAdapter(Context context, int resource, int textViewResourceId, List<Note> objects) {
    super(context, resource, textViewResourceId, objects);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Creating the row
    View row = super.getView(position, convertView, parent);

    // Changing the text of time and date
    ((TextView)row.findViewById(R.id.noteTitle)).setText(getItem(position).getTitle());
    ((TextView)row.findViewById(R.id.noteTime)).setText(getItem(position).getTime());
    ((TextView)row.findViewById(R.id.noteDate)).setText(getItem(position).getDate());

    ((TextView)row.findViewById(R.id.noteTitle)).setTextColor(Color.parseColor(getItem(position).getColor()));

    // Returning the row
    return row;
    }
}

And in the Main activity this is how I implement it:

...
NoteAdapter adapter;
NotesManager manager;
private Note nNoteToDelete;
ArrayList<Note> lstAllNotes;

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

    // Setting onClickListener for the "Add note" button when the activity starts
    findViewById(R.id.btnAddNewNote).setOnClickListener(addNewNote);

    // INSTANTIATING

    // Manager - to manage all the DB manipulations
    manager = new NotesManager(this);

    // Retrieving all the notes in the DB
    lstAllNotes = manager.getAllNotes();

    // Setting the ArrayAdapter, to display retrieved data in the ListView
    //adapter = new ArrayAdapter<Note>(this, R.layout.note, lstAllNotes);
    adapter = new NoteAdapter(this, R.layout.main, R.id.noteTitle, lstAllNotes);

    // Setting the ListAdapter
    setListAdapter(adapter);

    // Registering for a single click action for each item in the ListView
    getListView().setOnItemClickListener(editNote);

    // Registering for a long click, which will pop up a context menu
    registerForContextMenu(getListView());

}
...

But when I test the app, it immediately crashes. I’m getting these errors in LogCat:

08-08 08:59:52.291: E/AndroidRuntime(21268): FATAL EXCEPTION: main
08-08 08:59:52.291: E/AndroidRuntime(21268): java.lang.NullPointerException
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at com.notepad.NoteAdapter.getView(NoteAdapter.java:24)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.AbsListView.obtainView(AbsListView.java:2267)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.ListView.onMeasure(ListView.java:1156)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.View.measure(View.java:15172)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.View.measure(View.java:15172)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.View.measure(View.java:15172)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.View.measure(View.java:15172)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2148)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.View.measure(View.java:15172)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.Choreographer.doFrame(Choreographer.java:525)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.os.Handler.handleCallback(Handler.java:615)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.os.Looper.loop(Looper.java:137)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at android.app.ActivityThread.main(ActivityThread.java:4745)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at java.lang.reflect.Method.invokeNative(Native Method)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at java.lang.reflect.Method.invoke(Method.java:511)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-08 08:59:52.291: E/AndroidRuntime(21268):    at dalvik.system.NativeStart.main(Native Method)

What am I missing here? Why does it keep crashing and how do I fix it?

  • 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-09T15:24:55+00:00Added an answer on June 9, 2026 at 3:24 pm

    Try this:

    public class NoteAdapter extends ArrayAdapter<Note> {
    
        LayoutInflater mInflater;
        List<Note> list;
        public NoteAdapter(Context context, int resource, int textViewResourceId, List<Note> objects) {
            super(context, resource, textViewResourceId, objects);
            mInflater=LayoutInflater.from(context);
            list=objects;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
    
            final ViewHolder holder;
    
            if(convertView==null){
                 convertView=mInflater.inflate(R.layout.listitem_layout,null);// R.layout.listitem_layout is your custom layout file
                 holder=new ViewHolder();
    
                 holder.title=(TextView)convertView.findViewById(R.id.noteTitle);
                 holder.time=(TextView)convertView.findViewById(R.id.noteTime);
                 holder.date=(TextView)convertView.findViewById(R.id.noteDate);
                 convertView.setTag(holder);
            }
            else{
                 holder=(ViewHolder)convertView.getTag();
            }
    
            Note note=list.get(position);
    
            holder.title.setText(note.getTitle());
            holder.title.setTextColor(Color.parseColor(note.getColor()));
            holder.time.setText(note.getTime());
            holder.date.setText(note.getDate());      
    
            return convertView;
        }
        class ViewHolder{
            TextView title;
            TextView time;
            TextView date;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.