Redundant error for Android Studio (java) code - java

This is a Calculator program where several inputs are used to create several outputs. The single button on the App that I'm writing runs all the calculations then gives the outputs.
I'm getting one consistent "warning" on the lines under public void onClick
The warning is: Variable 'aResult' initializer 'Double.parseDouble(tvaResult.getText().toString())' is redundant
package com.example.ericallenbellville.rcbeamdesign;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button btnCalc;
private TextView tvaResult;
private TextView tvcResult;
private TextView tvetResult;
private TextView tvphiResult;
private TextView tvMnResult;
private TextView tvphiMnResult;
private TextView tvbeta1Result;
private EditText etB,etD,etAs,etFc,etFy;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
private void init() {
btnCalc = (Button)findViewById(R.id.btnCalc);
etB = (EditText)findViewById(R.id.etB);
etD = (EditText)findViewById(R.id.etD);
etAs = (EditText)findViewById(R.id.etAs);
etFc = (EditText)findViewById(R.id.etFc);
etFy = (EditText)findViewById(R.id.etFy);
tvaResult = (TextView)findViewById(R.id.tvaResult);
tvcResult = (TextView)findViewById(R.id.tvcResult);
tvetResult = (TextView)findViewById(R.id.tvetResult);
tvphiResult = (TextView)findViewById(R.id.tvphiResult);
tvMnResult = (TextView)findViewById(R.id.tvMnResult);
tvphiMnResult = (TextView)findViewById(R.id.tvphiMnResult);
tvbeta1Result = (TextView)findViewById(R.id.tvbeta1Result);
btnCalc.setOnClickListener(this);
}
#Override
public void onClick(View view) {
btnCalc = (Button)findViewById(R.id.btnCalc);
Double B = Double.parseDouble(etB.getText().toString());
Double D = Double.parseDouble(etD.getText().toString());
Double As = Double.parseDouble(etAs.getText().toString());
Double Fc = Double.parseDouble(etFc.getText().toString());
Double Fy = Double.parseDouble(etFy.getText().toString());
Double aResult = Double.parseDouble(tvaResult.getText().toString());
Double cResult = Double.parseDouble(tvcResult.getText().toString());
Double etResult = Double.parseDouble(tvetResult.getText().toString());
Double beta1Result = Double.parseDouble(tvbeta1Result.getText().toString());
Double phiResult = Double.parseDouble(tvphiResult.getText().toString());
Double MnResult = Double.parseDouble(tvMnResult.getText().toString());
Double phiMnResult = Double.parseDouble(tvphiMnResult.getText().toString());
switch(view.getId() ) {
case R.id.btnCalc:
if (Fc <= 4000) {
beta1Result = (0.85);
} else if (4000 < Fc && Fc <= 8000) {
beta1Result = ((0.85)-(0.05 * ((Fc - 4000) / (1000))));
} else {
beta1Result = 0.65;
}
aResult = ((Fy * As) / (0.85 * Fc * B));
cResult = (aResult / beta1Result);
etResult = (((D - cResult) / (cResult)) * 0.003);
if (etResult >= 0.005) {
phiResult = (0.9);
} else if (0.002 <= etResult && etResult < 0.005) {
phiResult = (0.65 + (etResult - 0.002) * 0.25 / (0.005 - 0.002));
} else {
phiResult = (0.00);
}
MnResult = (((Fy * As) * (D - (aResult / 2.0))));
phiMnResult = phiResult * MnResult;
tvaResult.setText(String.valueOf(aResult));
tvcResult.setText(String.valueOf(cResult));
tvetResult.setText(String.valueOf(etResult));
tvphiResult.setText(String.valueOf(phiResult));
tvMnResult.setText(String.valueOf(MnResult));
tvphiMnResult.setText(String.valueOf(phiMnResult));
}}
}

Related

Android: Double Value dissappears inside textbox

A simple countdowntimer that updates the value of a double variable and then display the value onto the end of a textbox. I have done this with integers and it works fine, however when I use a double value it just simply disappears from the end of the textbox. Is there a reason for this occurance?
Code used:
PSICount = new CountDownTimer(5000,1000) {
#Override
public void onTick(long millisUntilFinished) {
timer2.setText("seconds remaining: " + millisUntilFinished / 1000);
}
#Override
public void onFinish() {
if(alti >= 33000){
Random r = new Random();
double Low = 0.2 ;
double High = 0.5;
double randomValue = Low + (High - Low) * r.nextDouble();
pressure = pressure - randomValue;
pressureT.setText("Pressure: "+ pressure + " PSI");
}
PSICount.start();
}
};
PSICount.start();
This is the timer and it triggers every 5 seconds if the value of another variable is above 33000. As soon as that variable reaches 33000, the textbox (which has a placeholder value of 10.0 at the end) does not display any value at the end. Do I need to do something to use doubles with textViews?
Thank you
My entire Class:
import android.content.pm.ActivityInfo;
import android.graphics.Typeface;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.Random;
public class flight_engineer extends AppCompatActivity {
int fuel = 100;
int alti = 10000;
int speed = 50;
double over_heat = 600;
double pressure = 10.0;
CountDownTimer fuelCount;
CountDownTimer PSICount;
CountDownTimer spike;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flight_engineer);
//sets screen orientation on created
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Typeface typeface = Typeface.createFromAsset(getAssets(), "Stencil WW.ttf");
final TextView fuelT = (TextView) findViewById(R.id.fuelText);
final TextView pressureT = (TextView) findViewById(R.id.presText);
final TextView altitudeT = (TextView) findViewById(R.id.altText);
final TextView speedT = (TextView) findViewById(R.id.speedText);
final TextView over_heatingT = (TextView) findViewById(R.id.heatText);
final TextView info = (TextView) findViewById(R.id.infoText);
final TextView timer = (TextView) findViewById(R.id.timer);
final TextView timer2 = (TextView) findViewById(R.id.timer2);
fuelT.setTypeface (typeface);
pressureT.setTypeface (typeface);
altitudeT.setTypeface (typeface);
speedT.setTypeface (typeface);
over_heatingT.setTypeface (typeface);
info.setTypeface(typeface);
fuelT.setText("Fuel: "+fuel);
pressureT.setText("Pressure: "+ pressure+ " PSI");
altitudeT.setText("Altitude: "+alti+" ft");
speedT.setText("Speed: "+speed+" MPH");
over_heatingT.setText("System Heat: "+over_heat+" °C");
Button speedPlus = (Button) findViewById(R.id.speedPlus);
speedPlus.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
fuelCount = new CountDownTimer(2000,1000) {
#Override
public void onTick(long millisUntilFinished) {
timer.setText("seconds remaining: " + millisUntilFinished / 1000);
}
#Override
public void onFinish() {
fuelCount.start();
fuel--;
fuelT.setText("Fuel: "+fuel);
over_heat=over_heat + 4;
fuelT.setText("Fuel: "+fuel);
over_heatingT.setText("System Heat: "+over_heat+" °C");
Random r = new Random();
int Low = 443;
int High = 872;
int Result = r.nextInt(High - Low) + Low;
alti = alti + Result;
altitudeT.setText("Altitude: "+alti+" ft");
}
};
fuelCount.start();
PSICount = new CountDownTimer(5000,1000) {
#Override
public void onTick(long millisUntilFinished) {
timer2.setText("seconds remaining: " + millisUntilFinished / 1000);
}
#Override
public void onFinish() {
if(alti >= 33000){
Random r = new Random();
double Low = 0.2 ;
double High = 0.5;
double randomValue = Low + (High - Low) * r.nextDouble();
pressure = pressure - randomValue;
pressureT.setText("Pressure: "+ pressure + " PSI");
}
PSICount.start();
}
};
PSICount.start();
spike = new CountDownTimer(30000,1000) {
#Override
public void onTick(long millisUntilFinished) {
}
#Override
public void onFinish() {
spike.start();
over_heat = over_heat + 50;
over_heatingT.setText("System Heat: "+over_heat+" °C");
alti = alti + 1000;
altitudeT.setText("Altitude: "+alti+" ft");
if(speed < 300 || speed > 300) {
Random r = new Random();
int Low = -50;
int High = 50;
int Result = r.nextInt(High - Low) + Low;
speed = speed + Result;
speedT.setText("Speed: " + speed + " MPH");
}
}
};
spike.start();
}
}

SQLite Java Android, not finding column to delete

I have a main activity where you can send a log to a database, and a log activity where you can view them and delete them. Everything works expect when I try and delete a single log, the program crashes and the error is saying that it can't find the column "identity" to delete it.
Main Activity:
package com.software.roux.diabcalc;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
public class MainActivity extends AppCompatActivity {
SharedPreferences mPrefs;
SharedPreferences logPrefs;
SQLiteDatabase db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SharedPreferences settings = getSharedPreferences("PREFS_NAME", 0);
boolean rb0 = settings.getBoolean("accepted", false);
if(rb0 == true){
setTitle("MyInsulin");
mPrefs=this.getSharedPreferences("settings", 0);
logPrefs=this.getSharedPreferences("logs", 0);
final EditText a1 = (EditText) findViewById(R.id.add1);
final EditText a2 = (EditText) findViewById(R.id.add2);
final double bolusdose = Double.parseDouble(mPrefs.getString("bolus", "0"));
final double correctiondose = Double.parseDouble(mPrefs.getString("correction", "0"));
final double targetlow = Double.parseDouble(mPrefs.getString("low", "0"));
final double targethigh = Double.parseDouble(mPrefs.getString("high", "0"));
final double correctto = Double.parseDouble(mPrefs.getString("corrset", "0"));
String bolusString = mPrefs.getString("bolus", "0");
String corrString = mPrefs.getString("correction", "0");
String lowString = mPrefs.getString("low", "0");
String highString = mPrefs.getString("high", "0");
String correcttonum = mPrefs.getString("corrset", "0");
EditText b1 = (EditText)findViewById(R.id.bolus);
b1.setText(bolusString);
b1.setEnabled(false);
EditText b2 = (EditText)findViewById(R.id.correction);
b2.setText(corrString);
b2.setEnabled(false);
EditText b3 = (EditText)findViewById(R.id.targetlow);
b3.setText(lowString);
b3.setEnabled(false);
EditText b4 = (EditText)findViewById(R.id.targethigh);
b4.setText(highString);
b4.setEnabled(false);
EditText b5 = (EditText)findViewById(R.id.correcttonum);
b5.setText(correcttonum);
b5.setEnabled(false);
Button b6 = (Button)findViewById(R.id.setter);
b6.setEnabled(false);
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
db = openOrCreateDatabase("logDB", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS zlogtable('identity VARCHAR',bslevel VARCHAR,carbs VARCHAR,result VARCHAR);");
a1.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String currentlevelst = a1.getText().toString();
String carbseatenst = a2.getText().toString();
if (currentlevelst.length() >= 1) {
if (carbseatenst.length() >= 1) {
Double currentlevel = Double.parseDouble(a1.getText().toString());
Double carbseaten = Double.parseDouble(a2.getText().toString());
double firststep = 0;
if (currentlevel > targethigh) {
firststep = ((currentlevel - correctto) / correctiondose);
} else if (currentlevel < targetlow) {
firststep = ((currentlevel - targethigh) / correctiondose);
} else {
firststep = 0;
}
double secondstep = carbseaten / bolusdose;
double firstplussecond = firststep + secondstep;
BigDecimal result = new BigDecimal(firstplussecond, MathContext.DECIMAL64);
result = result.setScale(2, RoundingMode.CEILING);
if (result.compareTo(BigDecimal.ZERO) > 0) {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("Recommended Dose: " + result + " Units");
Button b8 = (Button) findViewById(R.id.logsave);
b8.setEnabled(true);
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("No Insulin Needed");
}
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("");
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
}
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("");
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
a2.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String currentlevelst = a1.getText().toString();
String carbseatenst = a2.getText().toString();
if (currentlevelst.length() >= 1) {
if (carbseatenst.length() >= 1) {
Double currentlevel = Double.parseDouble(a1.getText().toString());
Double carbseaten = Double.parseDouble(a2.getText().toString());
double firststep = 0;
if (currentlevel > targethigh) {
firststep = ((currentlevel - correctto) / correctiondose);
} else if (currentlevel < targetlow) {
firststep = ((currentlevel - targethigh) / correctiondose);
} else {
firststep = 0;
}
double secondstep = carbseaten / bolusdose;
double firstplussecond = firststep + secondstep;
BigDecimal result = new BigDecimal(firstplussecond, MathContext.DECIMAL64);
result = result.setScale(2, RoundingMode.CEILING);
if (result.compareTo(BigDecimal.ZERO) > 0) {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("Recommended Dose: " + result + " Units");
Button b8 = (Button) findViewById(R.id.logsave);
b8.setEnabled(true);
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("No Insulin Needed");
}
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("");
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
}
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("");
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
}else{
showDialog(0);
}}
public void addclickb(View b) throws InterruptedException {
if (b.getId() == R.id.add2) {
final EditText a1 = (EditText) findViewById(R.id.add1);
final EditText a2 = (EditText) findViewById(R.id.add2);
final double bolusdose = Double.parseDouble(mPrefs.getString("bolus", "0"));
final double correctiondose = Double.parseDouble(mPrefs.getString("correction", "0"));
final double targetlow = Double.parseDouble(mPrefs.getString("low", "0"));
final double targethigh = Double.parseDouble(mPrefs.getString("high", "0"));
final double correctto = Double.parseDouble(mPrefs.getString("corrset", "0"));
a2.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String currentlevelst = a1.getText().toString();
String carbseatenst = a2.getText().toString();
if (currentlevelst.length() >= 1) {
if (carbseatenst.length() >= 1) {
Double currentlevel = Double.parseDouble(a1.getText().toString());
Double carbseaten = Double.parseDouble(a2.getText().toString());
double firststep = 0;
if (currentlevel > targethigh) {
firststep = ((currentlevel - correctto) / correctiondose);
} else if (currentlevel < targetlow) {
firststep = ((currentlevel - targethigh) / correctiondose);
} else {
firststep = 0;
}
double secondstep = carbseaten / bolusdose;
double firstplussecond = firststep + secondstep;
BigDecimal result = new BigDecimal(firstplussecond, MathContext.DECIMAL64);
result = result.setScale(2, RoundingMode.CEILING);
if (result.compareTo(BigDecimal.ZERO) > 0) {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("Recommended Dose: " + result + " Units");
Button b8 = (Button) findViewById(R.id.logsave);
b8.setEnabled(true);
} else {
TextView t = (TextView) findViewById(R.id.answerobj);
t.setText("No Insulin Needed");
}
}
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
}
}
public void noweditable(View a) {
if (a.getId() == R.id.editbutton) {
EditText b1 = (EditText)findViewById(R.id.bolus);
EditText b2 = (EditText)findViewById(R.id.correction);
EditText b3 = (EditText)findViewById(R.id.targetlow);
EditText b4 = (EditText)findViewById(R.id.targethigh);
EditText b5 = (EditText)findViewById(R.id.correcttonum);
Button b6 = (Button)findViewById(R.id.setter);
Button b7 = (Button)findViewById(R.id.editbutton);
b1.setEnabled(true);
b2.setEnabled(true);
b3.setEnabled(true);
b4.setEnabled(true);
b5.setEnabled(true);
b6.setEnabled(true);
b7.setEnabled(false);
}
}
public void setclick(View b) {
if (b.getId() == R.id.setter) {
EditText b1 = (EditText)findViewById(R.id.bolus);
if (b1.length() > 0) {
String bolussave = "" + b1.getText().toString();
SharedPreferences.Editor mEditor1 = mPrefs.edit();
mEditor1.putString("bolus", bolussave).commit();
}
EditText b2 = (EditText)findViewById(R.id.correction);
if (b2.length() > 0) {
String corrsave = "" + b2.getText().toString();
SharedPreferences.Editor mEditor2 = mPrefs.edit();
mEditor2.putString("correction", corrsave).commit();
}
EditText b3 = (EditText)findViewById(R.id.targetlow);
if (b3.length() > 0) {
String lowsave = "" + b3.getText().toString();
SharedPreferences.Editor mEditor3 = mPrefs.edit();
mEditor3.putString("low", lowsave).commit();
}
EditText b4 = (EditText)findViewById(R.id.targethigh);
if (b4.length() > 0) {
String highsave = "" + b4.getText().toString();
SharedPreferences.Editor mEditor4 = mPrefs.edit();
mEditor4.putString("high", highsave).commit();
}
EditText b5 = (EditText)findViewById(R.id.correcttonum);
if (b4.length() > 0) {
String corrsetsave = "" + b5.getText().toString();
SharedPreferences.Editor mEditor5 = mPrefs.edit();
mEditor5.putString("corrset", corrsetsave).commit();
}
b1.setEnabled(false);
b2.setEnabled(false);
b3.setEnabled(false);
b4.setEnabled(false);
b5.setEnabled(false);
Button b6 = (Button)findViewById(R.id.setter);
Button b7 = (Button)findViewById(R.id.editbutton);
b6.setEnabled(false);
b7.setEnabled(true);
}
}
public void logview(View b){
if(b.getId() == R.id.logview)
{
Intent myIntent = new Intent(MainActivity.this, Settings.class);
MainActivity.this.startActivity(myIntent);
}
}
public void logsave(View b){
if(b.getId() == R.id.logsave)
{
EditText l1 = (EditText)findViewById(R.id.add1);
EditText l2 = (EditText)findViewById(R.id.add2);
TextView l3 = (TextView)findViewById(R.id.answerobj);
SharedPreferences.Editor mEditor6 = mPrefs.edit();
int incrementer = mPrefs.getInt("increment",0);
incrementer++;
mEditor6.putInt("increment", incrementer).commit();
db=openOrCreateDatabase("logDB", Context.MODE_PRIVATE, null);
db.execSQL("INSERT INTO zlogtable VALUES('"+incrementer+"','"+l2.getText()+"','"+
l1.getText()+"','"+l3.getText()+"');");
Button b8 = (Button)findViewById(R.id.logsave);
b8.setEnabled(false);
b8.setText("Saved To Log");
}
}
protected Dialog onCreateDialog(int id){
// show disclaimer....
// for example, you can show a dialog box...
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Legal Notice: The content provided through this app is for informational purposes only and does not constitute medical advice. Reliance on any information provided by this application is solely at your own risk.")
.setCancelable(false)
.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// and, if the user accept, you can execute something like this:
// We need an Editor object to make preference changes.
// All objects are from android.context.Context
SharedPreferences settings = getSharedPreferences("PREFS_NAME", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("accepted", true);
// Commit the edits!
editor.commit();
}
})
.setNegativeButton("Decline", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//nm.cancel(R.notification.running); // cancel the NotificationManager (icon)
System.exit(0);
}
});
AlertDialog alert = builder.create();
return alert;
}
}
Log Activity:
package com.software.roux.diabcalc;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class Settings extends AppCompatActivity {
SQLiteDatabase db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
setTitle("My Logs");
db=openOrCreateDatabase("logDB", Context.MODE_PRIVATE, null);
Cursor c=db.rawQuery("SELECT * FROM zlogtable", null);
if(c.getCount()==0)
{
System.out.print("Error");
return;
}
StringBuffer buffer=new StringBuffer();
while(c.moveToNext())
{
final TextView logfield = new TextView(this);
final LinearLayout layout = (LinearLayout) findViewById(R.id.loghold);
final LinearLayout layout1 = new LinearLayout(this);
final int identifier = c.getInt(0);
logfield.append("Blood Sugar Level: "+c.getString(2)+"\n");
logfield.append("Carbs Eaten: "+c.getString(1)+"\n");
logfield.append(""+c.getString(3)+"\n");
final Button deleter = new Button(this);
deleter.setText("Delete");
deleter.setTextSize(12);
layout1.addView(logfield);
layout1.addView(deleter);
layout.addView(layout1);
deleter.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
layout1.removeView(deleter);
layout1.removeView(logfield);
db=openOrCreateDatabase("logDB", Context.MODE_PRIVATE, null);
db.execSQL("DELETE FROM zlogtable WHERE identity = "+identifier+" ");
}
});
}
TextView log1 = (TextView) findViewById(R.id.log1);
log1.setText(buffer.toString());
}
public void switchclick(View a) {
if (a.getId() == R.id.backbutton) {
Intent myIntent = new Intent(Settings.this, MainActivity.class);
Settings.this.startActivity(myIntent);
}
}
}
Looks like there is no column named 'identity' in your database. Can you check the column name for your db table.
Rotwang commented and found an error with this statement, I removed the string markers and it worked perfectly:
This is wrong: "CREATE TABLE IF NOT EXISTS zlogtable('identity VARCHAR'. Remove the ' string markers.

Stucked on loops

I'm a just a beginner to android & java. I'm trying to build an app that will tell you if you win or lose base on the Martingale on gambling.
My concept is, you can set your money, target and the minimum bet.
for example is if I set my current money is 1000, and my target is to get 1100, and the minimum bet is 100, the app will auto run the function for example 10 times and calculate the win rate.
now I'm stucked, on how to ask the app calculate the win rate, I tried the code below, but it's not working.
public int winPercentage (){
int numberWin = 0;
for (int i = 0; i <= 10; i++) {
boolean win = calRate(double currentMoney, double theTarget, double minBet);
if (win) {
numberWin = numberWin + 1;
}
}
return numberWin;
}
My Full Java Code Here
package com.example.android.gambling;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void seeRate(View view) {
EditText cMoney = (EditText) findViewById(R.id.money);
double currentMoney = Double.parseDouble(cMoney.getText().toString());
EditText target = (EditText) findViewById(R.id.target);
double theTarget = Double.parseDouble(target.getText().toString());
EditText bet = (EditText) findViewById(R.id.bet);
double minBet = Double.parseDouble(bet.getText().toString());
TextView textview = (TextView)findViewById(R.id.textView);
textview.setText("You " + winPercentage());
}
public boolean calRate(double currentMoney, double theTarget, double minBet) {
while (currentMoney > minBet) {
boolean win = winRate();
if (win) {
currentMoney += minBet;
minBet = minBet;
}
else {
currentMoney -= minBet;
minBet *= 2;
}
if (currentMoney >= theTarget){
return true;
}
}
return false;
}
private boolean winRate() {
double d = Math.random();
if (d < 0.5)
return true;
else
return false;
}
public int winPercentage (){
int numberWin = 0;
for (int i = 0; i <= 10; i++) {
boolean win = calRate(double currentMoney, double theTarget, double minBet);
if (win){
numberWin = numberWin + 1;
}
}
return numberWin;
}
}
Edit
Now that i amend the code as below, the android studio shows no error, but when i try to emulate it, it can't be opened, keep showing (unfortunately, app has stopped)
package com.example.android.gambling;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
EditText cMoney = (EditText) findViewById(R.id.money);
double currentMoney = Double.parseDouble(cMoney.getText().toString());
EditText target = (EditText) findViewById(R.id.target);
double theTarget = Double.parseDouble(target.getText().toString());
EditText bet = (EditText) findViewById(R.id.bet);
double minBet = Double.parseDouble(bet.getText().toString());
boolean findRate = calRate(currentMoney, theTarget, minBet);
public void seeRate(View view) {
TextView textview = (TextView)findViewById(R.id.textView);
textview.setText("You " + winPercentage());
}
public boolean calRate(double currentMoney, double theTarget, double minBet) {
while (currentMoney>minBet){
boolean win = winRate();
if (win){
currentMoney += minBet;
minBet = minBet;
}
else {
currentMoney -= minBet;
minBet *= 2;
}
if (currentMoney>=theTarget){
return true;
}
}
return false;
}
private boolean winRate() {
double d = Math.random();
if (d < 0.5)
return true;
else
return false;
}
public int winPercentage (){
int numberWin = 0;
for (int i=0; i<=10; i++){
boolean win = calRate(currentMoney, theTarget, minBet);
if (win){
numberWin = numberWin + 1;
}
}
return numberWin/10*100;
}
}
You have to pass arguments to the method 'calRate() when you are calling it. No need to specify the type of the argument. Change the line to
boolean win = calRate(double currentMoney,double theTarget,double minBet);
to
boolean win = calRate(currentMoney, theTarget, minBet);
This will work.
Edit:
You have to define the variables, currentMoney, theTarget and minBet inside your method. To do so, you have two options.
Make them global: Define the variables outside the seeRate() method and use them.
Pass them as arguments to the winPercentage() method.
Define your winPercentage() as follows:
public int winPercentage (double currentMoney, double theTarget, double minBet) {
int numberWin = 0;
for (int i=0; i<=10; i++){
boolean win = calRate(currentMoney, theTarget, minBet);
if (win){
numberWin = numberWin + 1;
}
}
return numberWin;
}

Google Maps android IndexOutOfBoundsException

I am trying to get markers placed on the map and fly to their destination. within a forloop i have an if statement, i wish it to do this:
for(i loop){
If (array(i) == null{ spawn plane code}
else {move plane code}
here is the code:
package com.fly.plane;
import java.sql.Time;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.fly.plane.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.Projection;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.R.array;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.graphics.Point;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.support.v4.app.FragmentActivity;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.TextView;
public class MyMapActivity extends ListActivity {
private ProgressDialog pDialog;
// URL to get data JSON
private static String url = "http://edmundgentle.com/snippets/flights/api.php";
// JSON Node speeds
private static final String TAG_data = "data";
private static final String TAG_BEARING = "bearing";
private static final String TAG_SPEED = "speed";
private static final String TAG_ARR = "arr";
private static final String TAG_ARR_TIME = "time";
private static final String TAG_ARR_LAT = "lat";
private static final String TAG_ARR_LON = "lon";
private static final String TAG_DEP = "dep";
private static final String TAG_DEP_TIME = "time";
private static final String TAG_DEP_LAT = "lat";
private static final String TAG_DEP_LON = "lon";
// data JSONArray
JSONArray data = null;
// Hashmap for ListView
ArrayList<HashMap<String, Double>> contactList;
// Hashmap for ListView
ArrayList<Double> ct;
List<Marker> markers = new ArrayList<Marker>();
//final Handler handler;
private GoogleMap mMap;
public static final LatLng dest(Double alt,Double aln, int i){
//final double latitude = Double.parseDouble(alt);
//final double longitude = Double.parseDouble(aln);
return new LatLng(alt, aln);
}
public double latt = -15.48169437461;
public double lng = -15.48169437461;
public ArrayList<Integer> dLat;
public String[] markerList;
public String dlat;
public String dlon;
public String alat;
public String alon;
private int count;
public boolean wait = true;
//private Button startB;
public TextView text;
Timer timing;
double time = 600;
double timm = 1;
long timer = 18000000;
long newTime;
TextView tv, test;
Thread t;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_map);
contactList = new ArrayList<HashMap<String, Double>>();
ct = new ArrayList<Double>();
//ListView lv = getListView();
//create markers
new Getdata().execute();
// timer showing time of day in fast time
t = new Thread() {
#Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(600);
runOnUiThread(new Runnable() {
#Override
public void run() {
timer = timer +60000;
if (timer >= 64000000) timer = 18000000;
newTime = timer;
// update TextView here!
//String time = "HH:mm:ss";
//tv.setText(DateFormat.format(time , timer));
tv.setText(Double.toString(time));
test.setText(Double.toString(timm));
//tv.setText(Double.toString(contactList.get(20).get("time")));
//Timer();
}
});
}
} catch (InterruptedException e) {
}
}
};
tv = new TextView(this);
test = new TextView(this);
tv=(TextView)findViewById(R.id.timer);
test=(TextView)findViewById(R.id.test);
// run the mUpdateUITimerTask's run() method in 10 seconds from now
}
// animate each plane
public void animateMarker(final Marker marker , final LatLng toPosition,
final boolean hideMarker, final double spd) {
float speed = (float) spd;// Float.parseFloat(spd);
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj = mMap.getProjection();
Point startPoint = proj.toScreenLocation(marker.getPosition());
final LatLng startLatLng = proj.fromScreenLocation(startPoint);
final float duration = 10 * speed;
final Interpolator interpolator = new LinearInterpolator();
handler.post(new Runnable() {
#Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) ((float) elapsed
/ duration));
double lng = t * toPosition.longitude + (1 - t)
* startLatLng.longitude;
double lat = t * toPosition.latitude + (1 - t)
* startLatLng.latitude;
marker.setPosition(new LatLng(lat, lng));
if (t < 1.0) {
// Post again 16ms later.
handler.postDelayed(this, 16);
} else {
handler.postDelayed(this, 16);
if (hideMarker) {
marker.setVisible(false);
} else {
marker.setVisible(true);
}
}
}
});
}
public void Timer(){
//TimerTask tasknew = new TimerTask();
timing = new Timer();
timing.schedule(new CreateMarker(), 1000, 1000);
}
public String calcCurPos(double curlat, double curlon, double deslat, double deslon, double avgSpd, double bearing){
double distance = avgSpd * 0.0167;
// check if degrees or radians
//deslat = distance * Math.cosh(bearing);
//double retLat = curlat + deslat;
//double dPhi = Math.log(Math.tan(retLat/2+Math.PI/4)/Math.tan(curlat/2+Math.PI/4));
//double q = deslat/dPhi deslat/dPhi : Math.cos(curlat);
bearing = bearing * Math.PI / 180;
int radius = 6371;
double nextLat = Math.asin(Math.sin(curlat)* Math.cos(distance/radius)
+ Math.cos(curlat)*Math.sin(distance/radius)*Math.cos(bearing));
double nextLon = curlon + Math.atan2(Math.sin(bearing)* Math.sin(distance/ radius)
* Math.cos(curlat), Math.cos(distance/radius)-Math.sin(curlat) * Math.sin(nextLat));
nextLat = (nextLat * 180) / Math.PI;
nextLon = (nextLon * 180) / Math.PI;
/**
* Warning might want to convert them to string prior to return.
*/
return nextLat + ";" + nextLon;
}
public class CreateMarker extends TimerTask{
#Override
public void run() {
// TODO Auto-generated method stub
// print test
//tv.setText(Double.toString(time));
//tv.setText(Double.toString(time));
if (time >= 2400){
time=0;
}
time += 1;
//mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
for (int i =0; i < 100;i++){
// get data from array list
final double depLat = contactList.get(i).get("dlat");
final double depLon = contactList.get(i).get("dlon");
final double arLat = contactList.get(i).get("alat");
final double arLon = contactList.get(i).get("alon");
final double spd = contactList.get(i).get("speed");
final double dTime = contactList.get(i).get("time");
double curLat = contactList.get(i).get("clat");
double curLon = contactList.get(i).get("clon");
final double bearing = contactList.get(i).get("bearing");
final int j = i;
//int dTime = Integer.parseInt(dtime);
double oldLat = curLat;
if (time >= dTime)
{
if (curLat < arLat || curLat > 0){
String latlng = calcCurPos(curLat, curLon, arLat, arLon ,spd, bearing );
String[] values = latlng.split(";");
curLat = Double.parseDouble(values[0]);
curLon = Double.parseDouble(values[1]);
final double crLat = curLat;
final double crLon = curLon;
final LatLng position = new LatLng(crLat,crLon);
/*Marker mo = mMap.addMarker(new MarkerOptions()
.position(new LatLng(depLat, depLon))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.planemarker)));*/
//DrawMarker();
//animateMarker(markers.get(i), position , true, spd);
try{
if (markers.get(i) == null){
//timm += 1;
timm += 1;
runOnUiThread(new Runnable() {
#Override
public void run() {
final Marker marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(depLat, depLon))
.title("Hello world")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.planemarker)));
markers.add(marker);
//marker.setVisible(false);
//animateMarker(markers.get(j), new LatLng(arLat,arLon) , true, spd);
//Marker marker = markers.get(i);
//marker.setPosition(position);
}
});
}
else //(markers.get(i) != null){
{
Marker marker = markers.get(i);
marker.setPosition(position);
marker.setVisible(false);
//animateMarker(markers.get(i), position , true, spd);
}
}
catch(NullPointerException npe)
{
//do something else
}
}
}
}
//return null;
}
}
/**
* Async task class to get json by making HTTP call
* */
private class Getdata extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(MyMapActivity.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
// Creating service handler class instance
HTTPHandler sh = new HTTPHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url, HTTPHandler.GET);
Log.d("Response: ", "> " + jsonStr);
boolean limit = false;
if (jsonStr != null || limit == false) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
data = jsonObj.getJSONArray(TAG_data);
// looping through All data
for (int i = 0; i < data.length(); i++) {
JSONObject c = data.getJSONObject(i);
String bearing = c.getString(TAG_BEARING);
String spd = c.getString(TAG_SPEED);
// departure node is JSON Object
JSONObject dep = c.getJSONObject(TAG_DEP);
String dtime = dep.getString(TAG_DEP_TIME);
//String dlat = dep.getString(TAG_DEP_LAT);
//String dlon = dep.getString(TAG_DEP_LON);
dlat = dep.getString(TAG_DEP_LAT);
dlon = dep.getString(TAG_DEP_LON);
// replace : and last 2 0's from departure time
dtime = dtime.replaceAll(":","");
//dtime.replaceAll(";","");
dtime = dtime.substring(0,dtime.length()-2);
// arrival node is JSON Object
JSONObject arr = c.getJSONObject(TAG_ARR);
String alt = arr.getString(TAG_ARR_LAT);
String aln = arr.getString(TAG_ARR_LON);
// convert data positions to doubles for Google Maps + stuff
double brng = Double.parseDouble(bearing);
brng = brng * Math.PI / 180;
double speed = Double.parseDouble(spd);
//double brng = Double.parseDouble(bearing);
double dLatitude = Double.parseDouble(dlat);
double dLongitude = Double.parseDouble(dlon);
double aLatitude = Double.parseDouble(alt);
double aLongitude = Double.parseDouble(aln);
double cLatitude = Double.parseDouble(dlat);
double cLongitude = Double.parseDouble(dlon);
double dtme = Double.parseDouble(dtime);
// tmp hashmap for single contact
HashMap<String, Double> contact = new HashMap<String, Double>();
contact.put("bearing", brng);
contact.put("speed", speed);
contact.put("time", dtme);
contact.put("alat", aLatitude);
contact.put("alon", aLongitude);
contact.put("dlat", dLatitude);
contact.put("dlon", dLongitude);
contact.put("clat", cLatitude);
contact.put("clon", cLongitude);
// adding contact to contact list
contactList.add(contact);
if (i== data.length()){
wait = false;
}
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
// spawns planes when json loaded
#Override
protected void onPostExecute(Void result) {
Timer();
t.start();
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
// use plane api for latlon
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
//for (int i = 0; i < contactList.size() ; i++)
}}
}
and here is the error message:
02-26 21:53:42.031: E/AndroidRuntime(14970): FATAL EXCEPTION: Timer-0
02-26 21:53:42.031: E/AndroidRuntime(14970): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
02-26 21:53:42.031: E/AndroidRuntime(14970): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
02-26 21:53:42.031: E/AndroidRuntime(14970): at java.util.ArrayList.get(ArrayList.java:308)
02-26 21:53:42.031: E/AndroidRuntime(14970): at com.fly.plane.MyMapActivity$CreateMarker.run(MyMapActivity.java:395)
02-26 21:53:42.031: E/AndroidRuntime(14970): at java.util.Timer$TimerImpl.run(Timer.java:284)
i understand that the markers.get(i) is causing the problem, but i dont know how to check if the markers array is null without it throwing this error.
Any help would be appreciated.
You can use Map<Integer, Marker> (Integer are keys and Marker are values). Then you can leverage Map.get() which don't throws Exception if key is Integer and not null (your i will not be null in your code).
Declare markers as Map:
Map<Integer, Marker> markers = new HashMap<Integer, Marker>();
Inside CreateMarker.run() after final LatLng position = new LatLng(crLat,crLon); change as follows:
//implicit boxing to use int in Map
Integer ii = Integer.valueOf(i);
//try to get marker by index from map (index is the key)
Marker markerByIndex = markers.get(ii);
//Map.get() returns null if object by specified key is not in map
if (markerByIndex == null){
//marker doesn't exists - create it, add to Google Map and to Map by key
timm += 1;
runOnUiThread(new Runnable() {
#Override
public void run() {
final Marker marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(depLat, depLon))
.title("Hello world")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.planemarker)));
//put marker to map using i as a key
markers.put(ii, marker);
}
});
} else {
//marker exists, mutate it
markerByIndex.setPosition(position);
markerByIndex.setVisible(false);
//...replace the marker in map
markers.put(ii, markerByIndex);
//animate the marker
animateMarker(markerByIndex, position , true, spd);
}
You wrote:
i understand that the markers.get(i) is causing the problem, but i dont know how to check if the markers array is null without it throwing this error.
==> you can check it this way:
if (markers != null && markers.size() > 0) {
//there are actually markers. Calling markers.get(i) should work!
//...as long as i is smaller than markers.size()
} else {
//sorry, no markers! Don't call markers.get(i) here...
}

Getting the value in EditText Android

I am having a problem getting the value in the editText of my program. I set the value in a textView so that I can see if the code gets it. But unfortunately it displays something like this:
android.widget.EditText#410e5a58 -> the number after # sign changes every run in the emulator
Why this happens? This is my code:
package com.example.ITax;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
/**
* Created with IntelliJ IDEA.
* User: Karla Mae Jaro
* Date: 12/3/12
* Time: 3:58 PM
* To change this template use File | Settings | File Templates.
*/
public class AnnualComputation extends MyActivity
{
String civil_status2;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.annual_computation);
Bundle extras = getIntent().getExtras();
if(extras != null)
{
civil_status2 = extras.getString("user_status");
}
final Button btn_compute = (Button) findViewById(R.id.btn_compute_from_annual);
final Button btn_back = (Button) findViewById(R.id.btn_back_from_annual_computation);
btn_back.setOnClickListener(new Button.OnClickListener()
{
#Override
public void onClick(View v)
{
Intent i = new Intent(getApplicationContext(), OpenChoices.class);
startActivity(i);
}
});
btn_compute.setOnClickListener(new Button.OnClickListener()
{
#Override
public void onClick(View v)
{
final EditText net_salary = (EditText) findViewById(R.id.et_net_annual);
final EditText tax_due = (EditText) findViewById(R.id.et_taxdue);
final EditText tax_exe = (EditText) findViewById(R.id.et_taxexemption);
final TextView txt3 = (TextView) findViewById(R.id.textView3);
final TextView txt4 = (TextView) findViewById(R.id.textView4);
final TextView txt5 = (TextView) findViewById(R.id.textView5);
final TextView txt6 = (TextView) findViewById(R.id.textView6);
final TextView txt7 = (TextView) findViewById(R.id.textView7);
final TextView txt8 = (TextView) findViewById(R.id.textView8);
double netSalary, taxDue, rate = 0, exemption = 0, additional = 0, lowerlimit = 0, total;
String ns, td, r, e, a, t;
ns = net_salary.getText().toString();
netSalary = Double.parseDouble(ns);
/* Getting the tax exemption */
if ("SME".equals(civil_status2))
{
exemption = 50000;
}
else if ("SM1".equals(civil_status2))
{
exemption = 25000;
}
else if ("SM2".equals(civil_status2))
{
exemption = 50000;
}
else if ("SM3".equals(civil_status2))
{
exemption = 75000;
}
else if ("SM4".equals(civil_status2))
{
exemption = 100000;
}
/* Getting the rate, additional, lowerlimit */
if(netSalary <= 10000)
{
rate = 0.05;
}
else if((netSalary > 10000) && (netSalary <=30000))
{
rate = 0.1;
additional = 5000;
lowerlimit = 10000;
}
else if ((netSalary > 30000) && (netSalary <= 70000))
{
rate = 0.15;
additional = 2500;
lowerlimit = 30000;
}
else if((netSalary > 70000) && (netSalary <= 14000))
{
rate = 0.20;
additional = 8500;
lowerlimit = 70000;
}
else if ((netSalary > 140000) && (netSalary <= 250000))
{
rate = 0.25;
additional = 22500;
lowerlimit = 140000;
}
else if((netSalary > 250000) && (netSalary <= 500000))
{
rate = 0.30;
additional = 50000;
lowerlimit = 250000;
}
else if (netSalary > 500000)
{
rate = 0.32;
additional = 125000;
lowerlimit = 500000;
}
taxDue = netSalary - exemption;
total = taxDue - lowerlimit;
total = total * rate;
total = total + additional;
/* Converting exemption from Double to String */
td = String.valueOf(net_salary);
e = String.valueOf(exemption);
a = String.valueOf(additional);
r = String.valueOf(rate);
t = String.valueOf(total);
/* Placing the value to the editText (textbox) */
tax_due.setText(td);
tax_exe.setText(e);
txt3.setText(civil_status2);
txt4.setText(td);
txt5.setText(e);
txt6.setText(t);
txt7.setText(r);
txt8.setText(a);
}
});
}
}
use netSalary instead of net_salary
td = String.valueOf(netSalary);
As you are passing the edit text instead of the double variable
Try this,
tax_due.setText( net_salary.getText().toString());
If the problem is here:
td = String.valueOf(net_salary);
Then it is because you are trying to treat net_salary, a widget with a string value set in it, as if it were just a string. Try:
td = String.valueOf(net_salary.getText().toString());
You are passing an object of EditText(net_salary) in td so td will have the the string representation of your net_salary object.
You have stored your value in netSalary varibale so pass that instead :
td = String.valueOf(netSalary);
And for your information :
android.widget.EditText#410e5a58 is the string representation of your EditText object (i.e. calling toString method of your Edittext object will return this string) .
And value after # is the memory address of your object. And every time it changes because every time your object is created at different memory locations.

Categories

Resources