1. Download our Official Android App: Forums for Android!

Apps "unfortunately findingHouses has stopped"-Error

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

  1. Abisheak

    Abisheak Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    4
    Joined:
    Dec 21, 2013

    Dec 21, 2013
    4
    0
    25
    Male
    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
     

    Advertisement

  2. cybersa

    cybersa Newbie
    Rank:
    None
    Points:
    36
    Posts:
    36
    Joined:
    Dec 21, 2013

    Dec 21, 2013
    36
    2
    36
    Male
    I can't able to see your logcat.
    Post here i can help you.
     
  3. Abisheak

    Abisheak Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    4
    Joined:
    Dec 21, 2013

    Dec 21, 2013
    4
    0
    25
    Male
  4. cybersa

    cybersa Newbie
    Rank:
    None
    Points:
    36
    Posts:
    36
    Joined:
    Dec 21, 2013

    Dec 21, 2013
    36
    2
    36
    Male
    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
    Rank:
    None
    Points:
    25
    Posts:
    4
    Joined:
    Dec 21, 2013

    Dec 21, 2013
    4
    0
    25
    Male
    Thanks guys.Solved it .More of a GUI problem at runtime.Had to change EditText.
     

Share This Page

Loading...