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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:29:17+00:00 2026-06-03T02:29:17+00:00

I’m writing a recipe book, and I’ve encountered a problem – I want to

  • 0

I’m writing a recipe book, and I’ve encountered a problem – I want to send text from my recipe list to recipe display screen, and I must be doing something wrong because I keep getting force closes:

This is code for my Recipe_Button_List

public class Recipe_Button_List extends Activity {

EditText inputMethod;

EditText inputIngredients;

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

    inputMethod = (EditText) findViewById(R.id.textView2);
    inputIngredients = (EditText) findViewById(R.id.textView1);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);



    Button mainNext = (Button) findViewById(R.id.Recipe1);
    mainNext.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            final TextView mTextView = (TextView) findViewById(R.id.textView1);
            mTextView.setText(R.string.Test);
            Intent i= new Intent(getBaseContext(),recipedisplayscreen.class);
            //Sending data to the next screen
            i.putExtra("textView1", inputIngredients.getText().toString());
            i.putExtra("textView2", inputMethod.getText().toString());

            Log.e("n", inputMethod.getText()+"."+ inputIngredients.getText());

            startActivity(i);
        }
    });
}
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     MenuInflater inflater = getMenuInflater();
     inflater.inflate(R.menu.recipe_menu1, menu);
     return true;

}

}

And this is my recipe_display_screen:

public class recipedisplayscreen extends Activity {

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

    TextView MethodDisplay = (TextView) findViewById(R.id.textView2);
    TextView IngredientsDisplay = (TextView) findViewById(R.id.textView4);

    Intent i = getIntent();
    String Ingredients = i.getStringExtra("TextView1");
    String Method = i.getStringExtra("TextView2");
    Log.e("recipedisplayscreen", Ingredients + "." + Method);

    MethodDisplay.setText(Method);
    IngredientsDisplay.setText(Ingredients);


    ActionBar actionBar = getActionBar();
    setTitle(R.string.title);
    actionBar.setDisplayHomeAsUpEnabled(true);}

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                // App icon in action bar clicked; go home
                Intent intent = new Intent(this, MainScreen.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }




 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.recipe_menu1, menu);
        return true;

}

}

Here are records from logCat:

05-01 21:54:54.638: D/AndroidRuntime(10717): Shutting down VM
05-01 21:54:54.638: W/dalvikvm(10717): threadid=1: thread exiting with uncaught exception (group=0x40a301f8)
05-01 21:54:54.638: E/AndroidRuntime(10717): FATAL EXCEPTION: main
05-01 21:54:54.638: E/AndroidRuntime(10717): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bluStudios.Recipes4U.ics/com.bluStudios.Recipes4U.ics.Recipe_Button_List}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.os.Looper.loop(Looper.java:137)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-01 21:54:54.638: E/AndroidRuntime(10717): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 21:54:54.638: E/AndroidRuntime(10717): at java.lang.reflect.Method.invoke(Method.java:511)
05-01 21:54:54.638: E/AndroidRuntime(10717): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-01 21:54:54.638: E/AndroidRuntime(10717): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-01 21:54:54.638: E/AndroidRuntime(10717): at dalvik.system.NativeStart.main(Native Method)
05-01 21:54:54.638: E/AndroidRuntime(10717): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
05-01 21:54:54.638: E/AndroidRuntime(10717): at com.bluStudios.Recipes4U.ics.Recipe_Button_List.onCreate(Recipe_Button_List.java:25)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.Activity.performCreate(Activity.java:4465)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-01 21:54:54.638: E/AndroidRuntime(10717): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-01 21:54:54.638: E/AndroidRuntime(10717): … 11 more

PS Force close happens when I press the button that takes you to the recipe_button_list

EDIT:
Hi again 🙂
I’ve got another small problem – my recipe_display_screen recieves null.null form my previous screen any idea why?

LogCat:

05-02 11:28:29.764: D/dalvikvm(28455): GC_CONCURRENT freed 113K, 2% free 14526K/14727K, paused 2ms+14ms
05-02 11:28:30.022: E/n(28455): FromStringMethod.if this is displaying then Intent activity is working correctly
05-02 11:28:30.163: D/dalvikvm(28455): GC_FOR_ALLOC freed 1769K, 13% free 12813K/14727K, paused 23ms
05-02 11:28:30.163: I/dalvikvm-heap(28455): Grow heap (frag case) to 13.883MB for 1401676-byte allocation
05-02 11:28:30.202: D/dalvikvm(28455): GC_CONCURRENT freed 3K, 4% free 14179K/14727K, paused 2ms+2ms
05-02 11:28:30.218: E/recipedisplayscreen(28455): null.null

EDIT END

  • 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-03T02:29:19+00:00Added an answer on June 3, 2026 at 2:29 am

    Ah! you’re casting textviews to edit boxes. See the lines

    inputMethod = (EditText) findViewById(R.id.textView2);
    inputIngredients = (EditText) findViewById(R.id.textView1);
    

    change them to

    inputMethod = (TextView) findViewById(R.id.textView2);
    inputIngredients = (TextView) findViewById(R.id.textView1);
    

    and change the declarations of inputMethod and inputIngredients.

    Unless you meant them to be EditTexts, in which case you need to change that in your layout recipe_button_list

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a bunch of posts stored in text files formatted in yaml/textile (from
i want to parse a xhtml file and display in UITableView. what is the
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into

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.