-2

I am trying to do a EditText for a calc that calculate money. I want a EditText like this "$0.00", and I don't know how to do when i click on a button for example, button 1, put the 1 at final like "$0.01", and the next number "$0.11".

    <EditText
        android:id="@+id/etPantalla"
        android:drawableRight="@drawable/ic_launcher"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="false"
        android:ellipsize="end"
        android:ems="10"
        android:maxLength="8"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="right"
        android:longClickable="false"
        android:maxLines="1"
        android:singleLine="true"
        android:textSize="40sp" />
Rogui
  • 39
  • 5

2 Answers2

0

Put Drawableleft attribute to the edittext for example if this is your edittext

<EditText
    android:layout_below="@+id/tv_signup_descriptionError"
    android:id="@+id/et_signup_description"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dip"
    android:hint="@string/et_hint_enterDescription"
    android:singleLine="false"
    android:lines="5"
    android:gravity="top"
    android:scrollHorizontally="false"
    android:inputType="textMultiLine" 
    android:maxLines="5"
    />

put in this

android:drawableLeft="@drawable/ the dollar image"
Umer Kiani
  • 3,783
  • 5
  • 36
  • 63
0

Duplicate of: How to use EditText onTextChanged event when i press the number?

EditText money = (EditText)findViewById(R.id.my_edit_text);
money.addTextChangedListener(new TextWatcher() {

    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // do what you need here
    } 

});
Community
  • 1
  • 1
thiagolr
  • 6,909
  • 6
  • 44
  • 64