android - setting strings equal to eachother in a popup -
i'm making type of calculator app calculates surface areas of weird shapes etc.. when measurements inputted, user clicks calculate,and result gets displayed. problem i'm having cant result string (z) equal 1 in popup... dearly appreciated because have been stuck on quite while now.
public class rectangular extends activity { edittext length; edittext width; edittext edge; edittext roll; textview tt; button calculate; double w=0; double x=0; double y=0; double z=0; double v=0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_rectangular); initcontrols(); //when calculation done, popup window inflates final button btnopenpopup = (button)findviewbyid(r.id.button8); btnopenpopup.setonclicklistener(new button.onclicklistener() { public void onclick(view arg0) { layoutinflater layoutinflater = (layoutinflater) getbasecontext() .getsystemservice(layout_inflater_service); view popupview = layoutinflater.inflate(r.layout.pop_up, null); final popupwindow popupwindow = new popupwindow( popupview, viewgroup.layoutparams.fill_parent, viewgroup.layoutparams.fill_parent); popupwindow.showatlocation(popupview, gravity.center, 0, 0); edittext rs = (edittext) popupview.findviewbyid(r.id.edittext6); rs.settext(double.tostring(z)); button btndismiss = (button) popupview.findviewbyid(r.id.button9); btndismiss.setonclicklistener(new button.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub popupwindow.dismiss(); } }); popupwindow.showasdropdown(btnopenpopup, 50, -30); } }); } //these initial controls calculation gets put string z private void initcontrols() { length=(edittext)findviewbyid(r.id.edittext); width=(edittext)findviewbyid(r.id.edittext2); edge=(edittext)findviewbyid(r.id.edittext3); roll=(edittext)findviewbyid(r.id.edittext4); tt=(textview)findviewbyid(r.id.edittext5); calculate=(button)findviewbyid(r.id.button8); calculate.setonclicklistener(new button.onclicklistener() {public void onclick (view v) { calculate();}}); } edittext input; edittext output; button one; private void calculate() { w=double.parsedouble(length.gettext().tostring()); x=double.parsedouble(width.gettext().tostring()); y=double.parsedouble(edge.gettext().tostring()); v=double.parsedouble(roll.gettext().tostring()); z=((x+y+y)*(y+y+w))/v; } public void clear (view v){ viewgroup group = (viewgroup) findviewbyid(r.id.scrollview); clearform(group); } private void clearform(viewgroup group) { (int = 0, count = group.getchildcount(); < count; ++i) { view view = group.getchildat(i); if (view instanceof edittext) { ((edittext)view).settext(""); } if(view instanceof viewgroup && (((viewgroup)view).getchildcount() > 0)) clearform((viewgroup)view); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_rectangular, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); }
}
Comments
Post a Comment