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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:21:48+00:00 2026-06-04T19:21:48+00:00

I’ve just started writing my first app. I have EditText field in which i

  • 0

I’ve just started writing my first app.
I have EditText field in which i want to get it’s content (text)…
I’ve created a new class with several fields, one of them is the target for the EditText field content.
If i create a local String var and writes :(When name is the local var.)
name=(order_name.getText().toString());
Everything works just fine.
But when i try to use a class I’ve created which contains a public String field :
order.setName(order_name.getText().toString());
I get an FC.
I also tried direct insertion from the value to the field, and when that crashed i tried using set function as shown.
The class was firstly created using Eclipse new class wizard, after that i recreated it using AndroidManifest.xml wizard.

Log :

06-01 17:06:42.104: E/AndroidRuntime(1190): FATAL EXCEPTION: main<br>
06-01 17:06:42.104: E/AndroidRuntime(1190): java.lang.NullPointerException<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.Sagi.MyOrders.new_order_activity$1.onClick(new_order_activity.java:46)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.view.View.performClick(View.java:2408)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.view.View$PerformClick.run(View.java:8816)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Handler.handleCallback(Handler.java:587)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Handler.dispatchMessage(Handler.java:92)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.os.Looper.loop(Looper.java:123)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at android.app.ActivityThread.main(ActivityThread.java:4627)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at java.lang.reflect.Method.invokeNative(Native Method)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at java.lang.reflect.Method.invoke(Method.java:521)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)<br>
06-01 17:06:42.104: E/AndroidRuntime(1190):     at dalvik.system.NativeStart.main(Native Method)

Thanks guys !

Code :

 public class new_order_activity extends Activity {
    DatabaseHelper DBHelper;
    // LAYOUT VARS
    Button saveButton,clearButton;
    EditText order_name,link,price;
    CheckBox paid,alert;
    DatePicker date;
    // LOCAL VARS
    Order order;
    String name1;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_order_layout);
    date = (DatePicker)findViewById(R.id.order_date_field);
    alert = (CheckBox)findViewById(R.id.alert_checkbox);
    paid = (CheckBox)findViewById(R.id.paid_checkbox);
    price = (EditText)findViewById(R.id.price_field);
    order_name = (EditText)findViewById(R.id.order_name_field);
    link = (EditText)findViewById(R.id.link_field);

    saveButton = (Button) findViewById(R.id.save_button);
    clearButton = (Button) findViewById(R.id.clear_button);
    DBHelper=new DatabaseHelper(this);

    saveButton.setOnClickListener(  
        new View.OnClickListener() {
            public void onClick(View view) {
Line46:             **order.setName(order_name.getText().toString());**
                order.link=link.getText().toString();
                order.price=price.getText().toString();
                order.paid=paid.isChecked();
                order.alert=alert.isChecked();
                order.year=date.getYear();
                order.month=date.getMonth();
                order.day=date.getDayOfMonth();
                submitOrder(order);
            }
        });
  • 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-04T19:21:49+00:00Added an answer on June 4, 2026 at 7:21 pm

    When you try to run setName on your order variable it isn’t instantiated yet, so it throws an exception because it doesn’t have an actual object to call the method on. You’ll need to instantiate it (call its constructor in whatever way you wish) in your onCreate method so that it is created with the Activity (unless you want to create a new order object every time you click – then instantiate it in your onClickListener function, but make sure it is before you try to set its name).

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.