TextArea value

You must Login before you can answer or comment on any questions.

Hi I'm trying to create an adroid calculator, I've created the buttons that input the numbers into a text area. Is it possible to use the text area value to evaluate the calculation. Also I've right justified the curser in the text area, is it possible to justify to the bottom as well. Any help would be much appreciated.

— asked 8 months ago by J T
2 Comments
  • please provide some code so we can have some idea of what you are trying to do. thx

    — commented 8 months ago by Aaron Saunders

  • Sorry Aaron I probably should of explained myself better. Here's a snippit of what I have, obviously there are more buttons etc. I'm still green at programming in general and this is my first app I've tried to create, so the API is still a little difficult to understand.

    What I'm trying to do is add the operands and operators to the text area by pressing the buttons and then having a function to calculate the result. As you can see I've right justified the text but I'd also like it justified to the bottom row as I'm using the same layout to do a binary calculator and would like to have the two operands over top of each other. Thanks.

    var textFeild = Ti.UI.createTextArea({
    top:10, font : {fontSize:40,fontFamily:'Marker Felt', fontWeight:'bold'}, textAlign: 'right', width:470,
    height:140,
    backgroundColor:"#fff", borderWidth:2, borderColor:'#bbb', }); win1.add(textFeild);

    var bONE = Titanium.UI.createButton({ title: '1', color:'#fff', font: { fontSize: 30}, top: posTop,
    left: 5,
    width:80,
    height:80,
    backgroundColor:"#727376" }); win1.add(bONE);

    bONE.addEventListener('click', function(e) { textFeild.value = textFeild.value + '1'; });

    var bEQUALS = Titanium.UI.createButton({ title: '=', color:'#fff', font: { fontSize: 50}, top: posTop,
    left: 300 - 2.5,
    width:80 + 95.25,
    height:80,
    backgroundColor:"#E58F38" }); win1.add(bEQUALS);

    bEQUALS.addEventListener('click', function(e) { textFeild.value = textField.value.eval('textFeild.value'); });

    win1.open();

    — commented 8 months ago by J T

Your Answer

Think you can help? Login to answer this question!