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

  • Home
  • SEARCH
  • 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 8425975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:25:21+00:00 2026-06-10T04:25:21+00:00

I have a layout where I have a listview. I have a layout for

  • 0

I have a layout where I have a listview. I have a layout for every item for this listview named: email_listview_item and this is code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:orientation="vertical" 
    android:layout_gravity="center_vertical"
    android:background="@color/antiquewhiter">

    <ImageView
        android:id="@+id/email_list_item_checkbox_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="30dp"
        android:src="@drawable/form2andcheckbox_android" />

    <TextView
        android:id="@+id/email_list_item_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp"
        android:layout_toRightOf="@+id/email_list_item_checkbox_icon"
        android:text="TextView" 
        android:textColor="@color/bisque"/>

    <ImageView
        android:id="@+id/email_listview_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="309dp"
        android:src="@drawable/apvpro_icon" />

</RelativeLayout>

I want to creat listview with that items but I got nullPointer. Can you help me why?
This is code my class:

public class ListFragment extends ListActivity{
    ListView listView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        listView = (ListView) findViewById(R.id.email_listview);
        String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
          "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
          "Linux", "OS/2" };

        // First paramenter - Context
        // Second parameter - Layout for the row
        // Third parameter - ID of the TextView to which the data is written
        // Forth - the Array of data
//      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
//        R.layout.email_list_item, android.R.id.text1, values);
        Email_list_view_adapter adapter = new Email_list_view_adapter(this, values);
        // Assign adapter to ListView
        listView.setAdapter(adapter); 
    }




}

email_list_view_adapter:

public class Email_list_view_adapter extends ArrayAdapter<String>{
    private final Context context;
    private final String values[];

    public Email_list_view_adapter(Context context, String[] values){
        super(context, R.layout.email_list_item, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.email_list_item, parent,false);
        TextView desription = (TextView) rowView.findViewById(R.id.email_list_item_text);
        ImageView image = (ImageView) rowView.findViewById(R.id.email_listview_image);
        desription.setText(values[position]);
        String s = values[position];
        if(s.startsWith("iPhone")){
            image.setImageResource(R.drawable.senddata_android);
        }else{
            image.setImageResource(R.drawable.senddata_selected_android);
        }

        return rowView;
    }

}

This is stack trace:

08-20 14:27:03.334: E/AndroidRuntime(9196): FATAL EXCEPTION: main
08-20 14:27:03.334: E/AndroidRuntime(9196): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spot.p2a/pdf2app.ListFragment}: java.lang.NullPointerException
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread.access$1500(ActivityThread.java:122)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.os.Looper.loop(Looper.java:132)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread.main(ActivityThread.java:4025)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at java.lang.reflect.Method.invokeNative(Native Method)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at java.lang.reflect.Method.invoke(Method.java:491)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at dalvik.system.NativeStart.main(Native Method)
08-20 14:27:03.334: E/AndroidRuntime(9196): Caused by: java.lang.NullPointerException
08-20 14:27:03.334: E/AndroidRuntime(9196):     at pdf2app.ListFragment.onCreate(ListFragment.java:30)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
08-20 14:27:03.334: E/AndroidRuntime(9196):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
08-20 14:27:03.334: E/AndroidRuntime(9196):     ... 11 more
  • 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-10T04:25:22+00:00Added an answer on June 10, 2026 at 4:25 am

    you didn’t define the layout of your activity

     setContentView(R.layout.your_layout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather simple ListView row: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content
I have created an xml file like this: <?xml version=1.0 encoding=utf-8?> <ListView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
This is my ListView xml file and i have different xml for row(every item
enter code here I have a ListView that have a different Layout XML for
I have a ListView in my Layout. <ListView android:id=@+id/list_infoitems android:layout_width=fill_parent android:layout_height=wrap_content/> Every list item
I have an xml layout which I use for each row in my listview:
I have a listView with custom objects defined by the xml-layout below. I want
i have a listView with a custom BaseAdapter.Every list item has a clickable button.
I have a list view of items, every item has a layout with three
I have a ListView that is populated with 50 items. This is the xml

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.