0
저는 계산기에서 여러 작업을 수행하고자합니다 : 2+3*3/7
. 하는 방법. 어느 누구도 나를 도와 줄 수 없다. 계산기의 단일 작업이 작동합니다.계산기에 대한 안드로이드에서 한 번에 여러 작업을 계산하려면
하나의 작업을 여러 개 계산하는 방법 editText
. 이 코드는 동일 버튼 클릭 방식에 추가되었습니다. 다음은
btnEqualto.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String str2 = edtxt.getText().toString();
if (buttonPressed.equals("+"))
{
Log.e(TAG,"dot operation="+strDot);
if (strDot.equals("."))
{
Log.e(TAG, "If Codition :");
String str1[] = str2.split("[+]");
Log.e(TAG,"str1 ="+str1);
String strVal11 = str1[0];
String strVal22 = str1[1];
Log.e(TAG, "strValues :" + strVal11 + " & " + strVal22);
Double xx = Double.parseDouble(strVal11);
Double yy = Double.parseDouble(strVal22);
Log.e(TAG, "Value of x :" + xx + " AND y : " + yy);
Log.e(TAG, "dot operation");
Double result = xx + yy;
Log.e(TAG, "Result :" + result);
edtxt.setText(result + "");
Log.e(TAG, "VAlue of Result :" + edtxt);
}
else
{
Log.e(TAG, "If Codition :"+strVal2);
strDot = "";
String str1[] = str2.split("[+]");
strVal1 = str1[0];
strVal2 = str1[1];
Log.e(TAG, "Esle Condition 4 Pllus strValues :" + strVal1 + " & " + strVal2);
x = Integer.parseInt(strVal1);
y = Integer.parseInt(strVal2);
Log.e(TAG, "Value of x :" + x + " AND y : " + y);
int result = x + y;
Log.e(TAG, "Result :" + result);
edtxt.setText(result + "");
Log.e(TAG, "VAlue of Result :" + edtxt);
}
}
}
}
);
당신이지고 어떤 오류 .. 그것을 시도하고이 당신을 위해 작동하는지? Eclipse LogCat 창 (전체 빨간색 부분)에서 텍스트를 게시하십시오. – user113215
그리고 '사용하지 않은'경고를 억제하지 마십시오. – zmbq