public void updateDisplay(View v)
{
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
tempNumber.setText(tempNumber.getText().toString() + ((Button) view).getText());
}
});
tempNumber.setText( tempNumber.getText().toString() + ((Button) v).getText() );
}
My Java code:
<Button
android:id="@+id/button1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:background="@drawable/button"
android:onClick="updateDisplay"
android:text="1"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textColor="@drawable/button_tx_color"
android:textSize="15sp" />
My XML code:
When I click buttons from 0 to 9, I create numbers. But I also got dot . and minus - signs. How can I check in my textview to allow only one dot in my numbers and allow minus at the top of my number?