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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:52:25+00:00 2026-06-18T19:52:25+00:00

My app is crashing. I have errors and I just got done debugging and

  • 0

My app is crashing. I have errors and I just got done debugging and as the title says thats the problem.

While debugging I found the line that is causing the problem:

listView.setAdapter(arrayAdapter2);

Towards the bottom. I had a similar nullpointerException before here. This time it is different as I am declaring my arrayadapter in the right area. In debugging the result that goes into the array adapter is not NULL.

I have searched the forum and found these:

Why am I getting an InvocationTargetException? Android 2D game

another nullpointerexception

These NullPointerExceptions seem pretty common in android but they are pretty code specific.

In reading the other information correct me if I am wrong the only place the null can be is if the arrayAdapter2 is NULL.

public class ByZipcode extends Activity{ 
Button btngetLObyzipcode;
Spinner spinner1;
ProgressBar progressBar1;
EditText textinput4byzip;
UserFunctions userFunctions  = new UserFunctions();
ArrayAdapter<String> arrayAdapter2;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.byzipcodepage);
    arrayAdapter2 = new ArrayAdapter<String>(ByZipcode.this,android.R.layout.simple_list_item_1);

    // Initializing spinner with predetermined results
    spinner1 = (Spinner) findViewById(R.id.spinner1);
    progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
    textinput4byzip = (EditText) findViewById(R.id.textinput4byzip);
    ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(this,
            R.array.byzipspinner, android.R.layout.simple_spinner_item);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner1.setAdapter(spinnerAdapter);


    btngetLObyzipcode = (Button) findViewById(R.id.btngetLObyzipcode);
    btngetLObyzipcode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (textinput4byzip.getText() != null & textinput4byzip.getText().toString().length() == 5 ){
                progressBar1.setVisibility(View.VISIBLE);
                new DownloadDataTask().execute();
                }
            }
    });

}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main_screen, menu);
    return true;
}

private class DownloadDataTask extends AsyncTask<JSONArray, JSONArray, ArrayList<String> > {


        @Override
        protected ArrayList<String> doInBackground(JSONArray... params) {
            String spinValue = spinner1.getSelectedItem().toString();
            //if(textinput4byzip.getText() != null)
            JSONArray json = userFunctions.getCustomerbyZipCode((textinput4byzip.getText().toString()), spinValue);
            ArrayList<String> customers = new ArrayList<String>();
            for(int i=0; i < json.length() ; i++) {
                JSONObject jarray;
                try {
                    jarray = json.getJSONObject(i);
                    String zip = jarray.getString("CustomerName");
                    customers.add(zip);
                    Log.d(zip,"Output");
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return customers;
        }   
        protected void onPostExecute(ArrayList<String> result){
            ListView listView = (ListView) findViewById(R.id.listView1);
            arrayAdapter2.addAll(result);
            listView.setAdapter(arrayAdapter2);
            progressBar1.setVisibility(View.GONE);
            Intent viewCustomers = new Intent(getApplicationContext(), StoreListView.class);
            viewCustomers.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(viewCustomers);
        }
 }

}

Just in case you are interested the failure is below:

02-10 17:39:36.976: E/AndroidRuntime(7686): FATAL EXCEPTION: main
02-10 17:39:36.976: E/AndroidRuntime(7686): java.lang.NullPointerException
02-10 17:39:36.976: E/AndroidRuntime(7686):     at     com.example.lo.ByZipcode$DownloadDataTask.onPostExecute(ByZipcode.java:93)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at com.example.lo.ByZipcode$DownloadDataTask.onPostExecute(ByZipcode.java:1)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.os.AsyncTask.finish(AsyncTask.java:631)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.os.AsyncTask.access$600(AsyncTask.java:177)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.os.Looper.loop(Looper.java:137)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at android.app.ActivityThread.main(ActivityThread.java:5039)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at java.lang.reflect.Method.invokeNative(Native Method)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at java.lang.reflect.Method.invoke(Method.java:511)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-10 17:39:36.976: E/AndroidRuntime(7686):     at dalvik.system.NativeStart.main(Native Method)

As requested the xml page for the above activity:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<EditText
    android:id="@+id/textinput4byzip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|center_vertical"
    android:contentDescription="@string/zipcodefielddescription"
    android:ems="10"
    android:gravity="center_vertical|center_horizontal"
    android:inputType="number"
    android:maxLength="@integer/zipcodelength"
    android:textSize="@dimen/LargeFont" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical|center_horizontal"
    android:text="@string/entrzip"
    android:textAlignment="center"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textSize="@dimen/MediumFont" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_vertical|center_horizontal"
    android:orientation="vertical"
    android:paddingLeft="@dimen/MediumFont"
    android:paddingTop="@dimen/MediumFont" >

    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="285dp"
        android:layout_height="308dp"
        android:layout_gravity="center_horizontal|center_vertical"
        android:visibility="gone" />

    <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical"
        android:entries="@array/byzipspinner"
        android:textAlignment="center" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="@string/restaurants"
        android:textSize="@dimen/LargeFont" />

    <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="CheckBox"
        android:textSize="@dimen/LargeFont" />

    <CheckBox
        android:id="@+id/checkBox3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="CheckBox"
        android:textSize="@dimen/LargeFont" />

    <CheckBox
        android:id="@+id/checkBox4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="CheckBox"
        android:textSize="@dimen/LargeFont" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical|center_horizontal"
        android:orientation="vertical"
        android:paddingRight="@dimen/MediumFont" >

        <Button
            android:id="@+id/btngetLObyzipcode"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/getlo"
            android:textSize="@dimen/LargeFont" />

    </LinearLayout>

</LinearLayout>

  • 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-18T19:52:27+00:00Added an answer on June 18, 2026 at 7:52 pm
    ListView listView = (ListView) findViewById(R.id.listView1);
    

    You’re looking in byzipcodepage.xml for a ListView with ID listView1. No such view exists; in fact, there is no ListView in that layout at all.

    If you want a list in that view (for the adapter to use), you need to add it; if your ListView is within a different activity, you may need to handle this entire situation a bit differently to pass the data from this activity to that one (perhaps through a Bundle).

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

Sidebar

Related Questions

I have been trying to fix this problem for hours. My app keeps crashing
I have this problem of my app crashing (only when press a certain UIButton)
I have an Android app which is crashing on some phones, and not on
My app is crashing after loading thumbnails. On this line the code is downloading
I have a camera app that works on most phone but I got an
I have been getting errors while NSURLConnection delegate method connectionDidFinishLoading executes. Interestingly it works
I have a problem running an app on iOS 5 which works fine on
I am confused why my app is crashing with this error. I have implemented
I have a strange error in my app, which says: * Terminating app due
I've a rails app that I'm crashing on purpose.. it's local and I'm just

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.