1. Are you ready for the Galaxy S20? Here is everything we know so far!

"unfortunately findingHouses has stopped"-Error

Discussion in 'Android Development' started by Abisheak, Dec 21, 2013.

  1. Abisheak

    Abisheak Lurker
    Thread Starter

    Hello guys,
    I have a problem with my app.It crashes when i click the calc price button.It worked well before i did type casting from string to int and int to string.After that whenever i click the calc price button ,it just crashes.
    This is my logcat view.
    [​IMG]
    This is the app screen before it crashes
    [​IMG]

    This is the mainActivity.java:
    [HIGH]package com.example.findinghouses;

    import android.os.Bundle;
    import android.view.View;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.Menu;
    import android.widget.EditText;


    public class MainActivity extends Activity {
    public final static String FamilyIncome = "com.example.findinghouses.income";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    }

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

    public void calcPrice(View view){
    Intent intent = new Intent(this,CalcHousePrice.class);
    EditText editText1 = (EditText) findViewById(R.id.editText1);
    float income = Float.parseFloat(editText1.getText().toString());
    intent.putExtra(FamilyIncome, income);
    startActivity(intent);

    }

    }
    [/HIGH]

    This is the intent's Activity class(CalcHousePrice.class):
    [HIGH]package com.example.findinghouses;

    import android.os.Bundle;
    import android.content.Intent;
    import android.app.Activity;
    import android.view.MenuItem;
    import android.support.v4.app.NavUtils;
    import android.annotation.TargetApi;
    import android.os.Build;
    import android.widget.EditText;

    public class CalcHousePrice extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Show the Up button in the action bar.
    setupActionBar();
    Intent intent = getIntent();
    int income = Integer.parseInt(intent.getStringExtra(MainActivity.FamilyIncome));
    income = income * 4 * 100;
    String income1 = Integer.toString(income);
    EditText editText = new EditText(this);
    editText.setText(income1);
    editText.setTextSize(30);
    setContentView(editText);
    }

    /**
    * Set up the {@link android.app.ActionBar}, if the API is available.
    */
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void setupActionBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    getActionBar().setDisplayHomeAsUpEnabled(true);
    }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
    // This ID represents the Home or Up button. In the case of this
    // activity, the Up button is shown. Use NavUtils to allow users
    // to navigate up one level in the application structure. For
    // more details, see the Navigation pattern on Android Design:
    //
    // Navigation with Back and Up | Android Developers
    //
    NavUtils.navigateUpFromSameTask(this);
    return true;
    }
    return super.onOptionsItemSelected(item);
    }

    }[/HIGH]

    Thank you
     


  2. cybersa

    cybersa Newbie

    I can't able to see your logcat.
    Post here i can help you.
     
  3. Abisheak

    Abisheak Lurker
    Thread Starter

  4. cybersa

    cybersa Newbie

    Code looks good.
    It think you are tapping on button without entering required data.
    Input some value and then tap on calculate button.
     
  5. Abisheak

    Abisheak Lurker
    Thread Starter

    Thanks guys.Solved it .More of a GUI problem at runtime.Had to change EditText.
     
Loading...
Similar Threads - unfortunately findingHouses has
  1. Rob
    Replies:
    4
    Views:
    1,129
  2. Samsung android
    Replies:
    7
    Views:
    1,600
  3. Riya Patel
    Replies:
    1
    Views:
    726
  4. Greenveg
    Replies:
    8
    Views:
    4,921
  5. Christopher Worthy
    Replies:
    2
    Views:
    350
  6. nAtEe0323
    Replies:
    16
    Views:
    1,754
  7. qk44422
    Replies:
    0
    Views:
    774
  8. qk44422
    Replies:
    0
    Views:
    2,724
  9. Android_EPL
    Replies:
    7
    Views:
    773
  10. Epli
    Replies:
    6
    Views:
    4,106

Share This Page

Loading...