标签:over textutils alc src result oncreate cas toast hashmap
人品计算器
public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; @BindView(R.id.et) EditText mEt; @BindView(R.id.calculate) Button mCalculate; @BindView(R.id.clear) Button mClear; @BindView(R.id.name) TextView mName; @BindView(R.id.score) TextView mScore; @BindView(R.id.evaluate) TextView mEvaluate; private String mPinyin = ""; private HashMap<String, String> mMap; private int mScore1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); init(); } private void init() { AdManager.getInstance(this).init("ff8e2077f8854ed7", "9654791c307bf9da", false); mMap = new HashMap<>(); mMap.put("梁铁柱", "100"); mMap.put("成青青", "100"); mMap.put("鬼龟", "100"); mMap.put("cordy", "100"); mMap.put("jx2cordy", "100"); mMap.put("2 306205002", "100"); mMap.put("日本人", "-1"); mMap.put("小日本", "-1"); mMap.put("日本", "-1"); mMap.put("日本鬼子", "-1"); View bannerView = BannerManager.getInstance(this).getBannerView(this, mBannerViewListener); // 获取要嵌入广告条的布局 LinearLayout bannerLayout = (LinearLayout) findViewById(R.id.ll_banner); // 将广告条加入到布局中 bannerLayout.addView(bannerView); } private BannerViewListener mBannerViewListener = new BannerViewListener() { @Override public void onRequestSuccess() { } @Override public void onSwitchBanner() { } @Override public void onRequestFailed() { } }; @OnClick({R.id.calculate, R.id.clear}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.calculate: calculate(); break; case R.id.clear: //点击清空按钮,清空输入的姓名 mEt.setText(""); mPinyin = ""; break; } } private void calculate() { //获取用户的姓名 String name = mEt.getText().toString().trim(); //判断的输入的姓名是否为空 if (TextUtils.isEmpty(name)) { Toast.makeText(this, "姓名不能为空", Toast.LENGTH_SHORT).show(); } else { String value = Score.checkMap(name, mMap); if (value != null) { mScore1 = Integer.parseInt(value); } else { mScore1 = Score.getResult(name); } String evaluate = Score.getValue(mScore1); mName.setText(name); mScore.setText(((mScore1 >= 0 && mScore1 <= 100) ? mScore1 + "" : "负溢出")); mEvaluate.setText(evaluate); } } @Override protected void onDestroy() { super.onDestroy(); OffersManager.getInstance(this).onAppExit(); } }
public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; @BindView(R.id.et) EditText mEt; @BindView(R.id.calculate) Button mCalculate; @BindView(R.id.clear) Button mClear; @BindView(R.id.name) TextView mName; @BindView(R.id.score) TextView mScore; @BindView(R.id.evaluate) TextView mEvaluate; private String mPinyin = ""; private HashMap<String, String> mMap; private int mScore1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); init(); } private void init() { AdManager.getInstance(this).init("ff8e2077f8854ed7", "9654791c307bf9da", false); mMap = new HashMap<>(); mMap.put("梁铁柱", "100"); mMap.put("成青青", "100"); mMap.put("鬼龟", "100"); mMap.put("cordy", "100"); mMap.put("jx2cordy", "100"); mMap.put("2 306205002", "100"); mMap.put("日本人", "-1"); mMap.put("小日本", "-1"); mMap.put("日本", "-1"); mMap.put("日本鬼子", "-1"); View bannerView = BannerManager.getInstance(this).getBannerView(this, mBannerViewListener); // 获取要嵌入广告条的布局 LinearLayout bannerLayout = (LinearLayout) findViewById(R.id.ll_banner); // 将广告条加入到布局中 bannerLayout.addView(bannerView); } private BannerViewListener mBannerViewListener = new BannerViewListener() { @Override public void onRequestSuccess() { } @Override public void onSwitchBanner() { } @Override public void onRequestFailed() { } }; @OnClick({R.id.calculate, R.id.clear}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.calculate: calculate(); break; case R.id.clear: //点击清空按钮,清空输入的姓名 mEt.setText(""); mPinyin = ""; break; } } private void calculate() { //获取用户的姓名 String name = mEt.getText().toString().trim(); //判断的输入的姓名是否为空 if (TextUtils.isEmpty(name)) { Toast.makeText(this, "姓名不能为空", Toast.LENGTH_SHORT).show(); } else { String value = Score.checkMap(name, mMap); if (value != null) { mScore1 = Integer.parseInt(value); } else { mScore1 = Score.getResult(name); } String evaluate = Score.getValue(mScore1); mName.setText(name); mScore.setText(((mScore1 >= 0 && mScore1 <= 100) ? mScore1 + "" : "负溢出")); mEvaluate.setText(evaluate); } } @Override protected void onDestroy() { super.onDestroy(); OffersManager.getInstance(this).onAppExit(); } }
标签:over textutils alc src result oncreate cas toast hashmap
原文地址:https://www.cnblogs.com/nangongyibin/p/10229192.html