나는 하나의 필드 계산기를 만들기 위해 안드로이드 스튜디오에서 일하고있다계산기 한 필드를 기반으로
그것은 하나의 텍스트 필드, 버튼 및 다른 텍스트보기 일 것이다. 예를 들어 "2 + 5 * 6"을 입력하면 작동을 이해해야합니다.
아무도 도와 줄 수 있습니까? 내 코드 밖으로
점검
public class MainActivity extends AppCompatActivity {
public static final String equation = "[0-9]";
String opr = " ";
int[] result;
int castedInt;
String temp;
String[] separated;
EditText txte;
TextView txtv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buResult(View view) {
txte = (EditText)findViewById(R.id.editText);
for (int i = 0; i < txte.length(); i++) {
if (Pattern.matches(txte.toString(), equation)) {
separated[i] = txte.toString();
temp = separated[i];
castedInt = Integer.parseInt(temp.toString());
result[i] = castedInt;
}
else {
opr = txte.toString();
}
txtv.setText(result[i] + opr + result[i]);
}
}
}