private void showUserHashDialog() { String userHash = NavigineApp.Settings.getString("user_hash", ""); LayoutInflater inflater = getLayoutInflater(); View view = inflater.inflate(R.layout.user_hash_dialog, null); _userEdit = (EditText) view.findViewById(R.id.user_hash_edit); _userEdit.setText(userHash); _userEdit.setTypeface(Typeface.MONOSPACE); // _userEdit.addTextChangedListener(new TextWatcher() // { // public void afterTextChanged(Editable s) { } // public void beforeTextChanged(CharSequence s, int start, int count, int after) { } // public void onTextChanged(CharSequence s, int start, int before, int count) // { // String text = _userEdit.getText().toString(); // int length = _userEdit.getText().length(); // // if (text.endsWith("-")) // return; // // if (count <= before) // return; // // if (length == 4 || length == 9 || length == 14) // { // _userEdit.setText((text + "-")); // _userEdit.setSelection(length + 1); // } // } // }); AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext); alertBuilder.setView(view); alertBuilder.setTitle("Enter user ID"); alertBuilder.setNegativeButton( getString(R.string.cancel_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) {} }); alertBuilder.setPositiveButton( getString(R.string.ok_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dlg, int id) { String userHash = _userEdit.getText().toString(); SharedPreferences.Editor editor = NavigineApp.Settings.edit(); editor.putString("user_hash", userHash); editor.commit(); NavigineApp.applySettings(); refreshMapList(); } }); AlertDialog dialog = alertBuilder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
public void onClick(View v) { ContentResolver cr = getContentResolver(); switch (v.getId()) { // 전부 읽기 case R.id.readall: Cursor cursor = cr.query(Uri.parse(WORDURI), null, null, null, null); String Result = ""; while (cursor.moveToNext()) { String eng = cursor.getString(0); String han = cursor.getString(1); Result += (eng + " = " + han + "\n"); } if (Result.length() == 0) { mText.setText("Empyt Set"); } else { mText.setText(Result); } cursor.close(); break; // 하나만 읽기 case R.id.readone: Cursor cursor2 = cr.query(Uri.parse(WORDURI + "/boy"), null, null, null, null); String Result2 = ""; if (cursor2.moveToFirst()) { String eng = cursor2.getString(0); String han = cursor2.getString(1); Result2 += (eng + " = " + han + "\n"); } if (Result2.length() == 0) { mText.setText("Empyt Set"); } else { mText.setText(Result2); } cursor2.close(); break; // 삽입 case R.id.insert: ContentValues row = new ContentValues(); row.put("eng", "school"); row.put("han", "학교"); cr.insert(Uri.parse(WORDURI), row); mText.setText("Insert Success"); break; // 삭제 case R.id.delete: cr.delete(Uri.parse(WORDURI), null, null); mText.setText("Delete Success"); break; // 수정 case R.id.update: ContentValues row2 = new ContentValues(); row2.put("han", "핵교"); cr.update(Uri.parse(WORDURI + "/school"), row2, null, null); mText.setText("Update Success"); break; } }