文件名称:64进制任意转换
文件大小:145KB
文件格式:ZIP
更新时间:2021-08-24 11:35:30
进制转换
spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String str1=adapterView.getItemAtPosition(i).toString(); String str2=str1.substring(0, str1.indexOf("进")); try { input2=Integer.parseInt(str2.trim()); Toast.makeText(MainActivity.this,"输出的数为"+str1,Toast.LENGTH_LONG).show(); }catch (Exception ex){ ex.printStackTrace(); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { input3=editText1.getText().toString(); char ch[]=input3.toCharArray(); boolean isTrue=true; if(input3.equals("")){ Toast.makeText(MainActivity.this,"请输入您需要转换的数值",Toast.LENGTH_SHORT).show(); }else{ for (int i = 0; i<input3.length(); i++) { int index = numStr.indexOf(ch[i]); if(index>input1-1){ editText2.setText("error:请检查输入值与原进制是否合理!"); Toast.makeText(MainActivity.this,"输入有误!",Toast.LENGTH_SHORT).show(); isTrue=false; break; } } if(isTrue==true) { if(Integer.valueOf(input3).intValue()==0){ editText2.setText("0"); }else { Long tmp = N_to_10(input3, input1); String tmp2 = _10_to_N(tmp, input2); String newStr = tmp2.replaceFirst("^0*", ""); editText2.setText(newStr); } } } } });
【文件预览】:
64任意进制内转换
----20187291()
--------.gitignore(147B)
--------gradle()
--------build.gradle(573B)
--------gradlew.bat(2KB)
--------gradlew(5KB)
--------gradle.properties(739B)
--------settings.gradle(57B)
--------Converter()