Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - PLEASE SOMEONE HELP..I NEED ATTENTION FROM SENIORS

PLEASE SOMEONE HELP..I NEED ATTENTION FROM SENIORS

Put your problem here if it does not fit any of the other categories.

PLEASE SOMEONE HELP..I NEED ATTENTION FROM SENIORS

Postby AndroidGoal » Tue Nov 03, 2009 7:18 am

I am getting errors in my program.
I am getting error whenever I add the initcontrol(); method to the onCreate() method. I get errors and my application doesn't starts.
//thread main exiting due to uncaught execltion
//java.lang.runtime unable to start activity..........
and the main.xml page in the emulator never loads this happens only when I am adding the initcontrol(); method to the onCreate() method. I have the project file please help me.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package tip.cal;
  3.  
  4.  
  5.  
  6. import android.app.Activity;
  7.  
  8. import android.app.AlertDialog;
  9.  
  10. import android.content.DialogInterface;
  11.  
  12. import android.os.Bundle;
  13.  
  14. import android.view.View;
  15.  
  16. import android.view.View.OnClickListener;
  17.  
  18. import android.widget.Button;
  19.  
  20. import android.widget.EditText;
  21.  
  22.  
  23.  
  24. public class TipCalculator extends Activity {
  25.  
  26.        
  27.  
  28.         private EditText bill;
  29.  
  30.         private EditText tippercent;
  31.  
  32.         private EditText persons;
  33.  
  34.         private EditText tip;
  35.  
  36.         private EditText total;
  37.  
  38.         private EditText each;
  39.  
  40.         private Button calculate;
  41.  
  42.        
  43.  
  44.         //variables
  45.  
  46.         public double AmountOfTip;
  47.  
  48.         public double Percentage;
  49.  
  50.         public double Persons;
  51.  
  52.         public double TipAmount;
  53.  
  54.         double tipamount;
  55.  
  56.        
  57.  
  58.        
  59.  
  60.     /** Called when the activity is first created. */
  61.  
  62.     @Override
  63.  
  64.     public void onCreate(Bundle savedInstanceState) {
  65.  
  66.         super.onCreate(savedInstanceState);
  67.  
  68.        //setTheme(android.R.style.Theme_Black);
  69.  
  70.         setContentView(R.layout.main);
  71.  
  72.         initcontrol();
  73.  
  74.        
  75.  
  76.        
  77.  
  78.     }
  79.  
  80.    
  81.  
  82.     public void initcontrol(){
  83.  
  84.         bill = (EditText) findViewById(R.id.amount);
  85.  
  86.         tippercent = (EditText) findViewById(R.id.tip);
  87.  
  88.         persons = (EditText) findViewById(R.id.person);
  89.  
  90.         tip = (EditText) findViewById(R.id.tipamount);
  91.  
  92.         total = (EditText) findViewById(R.id.total);
  93.  
  94.         each = (EditText) findViewById(R.id.each);
  95.  
  96.         calculate = (Button) findViewById(R.id.calculate);
  97.  
  98.        
  99.  
  100.         calculate.setOnClickListener(new OnClickListener(){
  101.  
  102.  
  103.  
  104.                         public void onClick(View v) {
  105.  
  106.                                 // TODO Auto-generated method stub
  107.  
  108.                                         calculate();   
  109.  
  110.                         }
  111.  
  112.                
  113.  
  114.         });
  115.  
  116.     }
  117.  
  118.    
  119.  
  120.     public void calculate(){
  121.  
  122.         AmountOfTip = Double.parseDouble(bill.getText().toString());
  123.  
  124.         Percentage = Double.parseDouble(tippercent.getText().toString());
  125.  
  126.         Persons = Double.parseDouble(persons.getText().toString());
  127.  
  128.        
  129.  
  130.         boolean isError = false;
  131.  
  132.         if (AmountOfTip < 1.0){
  133.  
  134.                 showErrorAlert("Enter a valid number", bill.getId());
  135.  
  136.                 isError = true;
  137.  
  138.         }
  139.  
  140.        
  141.  
  142.         if (!isError){
  143.  
  144.                 tipamount = ((Percentage * AmountOfTip)/100);
  145.  
  146.                 tip.setText(Double.toString(tipamount));       
  147.  
  148.         }
  149.  
  150.     }
  151.  
  152.        
  153.  
  154.    
  155.  
  156.     private void showErrorAlert(String errorMessage,
  157.  
  158.             final int fieldId) {
  159.  
  160.             new AlertDialog.Builder(this).setTitle("Error")
  161.  
  162.             .setMessage(errorMessage).setNeutralButton("Close",
  163.  
  164.                     new DialogInterface.OnClickListener() {
  165.  
  166.                         public void onClick(DialogInterface dialog,
  167.  
  168.                                 int which) {
  169.  
  170.                             findViewById(fieldId).requestFocus();
  171.  
  172.                         }
  173.  
  174.                     }).show();
  175.  
  176.         }
  177.  
  178.  
  179.  
  180. }
Parsed in 0.018 seconds, using GeSHi 1.0.8.4
Attachments
Tipcalculator.zip
(31.86 KiB) Downloaded 53 times
AndroidGoal
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 29, 2009 2:54 am

Top

Postby Oleg » Tue Nov 03, 2009 10:58 am

Hi.
You have 3 errors.
1) in manifest remove point before TipCalculator
<activity android:name="TipCalculator"
2) you have duplication id in layout
<TextView android:text="person?" android:id="@+id/person"
android:layout_width="80px" android:layout_height="wrap_content"></TextView>
<EditText android:text="" android:id="@+id/person"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
Chage id for texview
3)In your code replace in showErrorAlert method
findViewById(fieldId).requestFocus(); with this one bill.requestFocus();
You don't need to send id in this method

Good luck
Oleg
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Wed Nov 28, 2007 1:49 pm
Location: Ukraine

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 12 guests