java - Dot function for android calculator -
i not able figure out way find method implement possibilities put dot decimal representation of numbers
the calculator has 1 text field (edittext) computes values there 2 operators first part solved , appends operator
some thing tried...
public void dot(view v) { if(count==1) { edittext et=(edittext) findviewbyid(r.id.edittext1); string input=et.gettext().tostring(); string[] parts=input.split("[+ - * /]"); if(parts[4].matches("[.]")){ return; } else{ et.append("."); } } else{ edittext et=(edittext) findviewbyid(r.id.edittext1); string input=et.gettext().tostring(); if(input.matches("[.]")) return; else{ if(input.length()==0) et.append("0"); et.append("."); } } }
count
keeps track of number of operators {values(0,1)}
Comments
Post a Comment