private Dialog locationPicker() { AlertDialog.Builder locationPickerBuilder = new AlertDialog.Builder(this); locationPickerBuilder.setTitle("Set task location"); View content = getLayoutInflater() .inflate(R.layout.editlocation, (ViewGroup) findViewById(R.id.editLocation)); locationPickerBuilder.setView(content); EditText longitudeText = (EditText) content.findViewById(R.id.longitudeText); EditText latitudeText = (EditText) content.findViewById(R.id.latitudeText); latitudeText.setText(String.valueOf(location().latitude())); longitudeText.setText(String.valueOf(location().longitude())); locationPickerBuilder.setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Dialog locationPicker = (Dialog) dialogInterface; EditText longitudeText = (EditText) locationPicker.findViewById(R.id.longitudeText); EditText latitudeText = (EditText) locationPicker.findViewById(R.id.latitudeText); double longitude = Double.valueOf(longitudeText.getText().toString()); double latitude = Double.valueOf(latitudeText.getText().toString()); task.add(TaskAdapter.LOCATION, new CMGeoPoint(longitude, latitude)); setLocation(); } }); return locationPickerBuilder.create(); }
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 mOnClick(View v) { switch (v.getId()) { case R.id.test: String rootdir = Environment.getRootDirectory().getAbsolutePath(); String datadir = Environment.getDataDirectory().getAbsolutePath(); String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath(); mEdit.setText( String.format( "ext = %s\nroot=%s\ndata=%s\ncache=%s", mSdPath, rootdir, datadir, cachedir)); break; case R.id.save: File dir = new File(mSdPath + "/dir"); dir.mkdir(); File file = new File(mSdPath + "/dir/file.txt"); try { FileOutputStream fos = new FileOutputStream(file); String str = "This file exists in SDcard"; fos.write(str.getBytes()); fos.close(); mEdit.setText("write success"); } catch (FileNotFoundException e) { mEdit.setText("File Not Found." + e.getMessage()); } catch (SecurityException e) { mEdit.setText("Security Exception"); } catch (Exception e) { mEdit.setText(e.getMessage()); } break; case R.id.load: try { FileInputStream fis = new FileInputStream(mSdPath + "/dir/file.txt"); byte[] data = new byte[fis.available()]; while (fis.read(data) != -1) {; } fis.close(); mEdit.setText(new String(data)); } catch (FileNotFoundException e) { mEdit.setText("File Not Found"); } catch (Exception e) {; } break; } }
@Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent); if ((actionId == EditorInfo.IME_ACTION_DONE) || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) { Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER"); String input = textView.getText().toString().trim(); if (input.length() > 0) { String result = ""; try { result += calculator.calculate(input); } catch (Exception e) { result = "no result (" + e.getMessage() + ")"; } if (listAdapter.getCount() > 0) { listAdapter.add(""); } listAdapter.add(input + " ="); if (input.indexOf("@") > -1) { listAdapter.add(calculator.getEquation() + " ="); } listAdapter.add(result); listAdapter.notifyDataSetChanged(); inputView.endBatchEdit(); inputView.setText(""); hideKeyboard(); } } return false; }
@Override public void onClick(View v) { TextView txtManageLabel, txtBrowseLabel, txtRefreshLabel, txtSearchLabel; txtManageLabel = (TextView) findViewById(R.id.txt_manage_label); txtBrowseLabel = (TextView) findViewById(R.id.txt_browse_label); txtRefreshLabel = (TextView) findViewById(R.id.txt_refresh_label); txtSearchLabel = (TextView) findViewById(R.id.txt_search_label); txtSearch.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { new AsyncTask<String, Void, ArrayList<RssItem>>() { @Override protected ArrayList<RssItem> doInBackground(String... params) { return dbQuery.searchRssItem(params[0]); } @Override protected void onPostExecute(ArrayList<RssItem> result) { rssList.clear(); rssList.addAll(result); rssAdapter.config().notifyDataSetChanged(); } }.execute(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void afterTextChanged(Editable s) {} }); txtSearch.setOnKeyListener( new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) return true; return false; } }); switch (v.getId()) { case R.id.btn_manage: startActivityForResult( new Intent(RssReaderActivity.this, RssManageActivity.class), REQ_RSS_MANAGE); break; case R.id.btn_browse: rssProvider = dbQuery.getRssProviderList(null); int length = rssProvider.getProviderNames().length; if (length == 0) break; String[] providers = new String[length + 1]; providers[0] = "All"; for (int i = 0; i < length; i++) providers[i + 1] = rssProvider.getProviderNames()[i]; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle(R.string.rss_choose_provider) .setItems( providers, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (item == 0) { loadData(null, true, false, false); return; } loadData(rssProvider.getProviderNames()[item - 1], false, false, false); curProvider = item - 1; updateListView(); } }); builder.create().show(); break; case R.id.btn_refresh: if (curProvider == -1) loadData(null, true, true, true); else loadData( dbQuery.getRssProviderList(null).getProviderNames()[curProvider], false, true, true); break; case R.id.btn_search: if (txtSearchLabel.getText().toString().equals(getString(R.string.btn_search_text))) { btnManage.setVisibility(View.GONE); txtManageLabel.setVisibility(View.GONE); btnBrowse.setVisibility(View.GONE); txtBrowseLabel.setVisibility(View.GONE); btnRefresh.setVisibility(View.GONE); txtRefreshLabel.setVisibility(View.GONE); btnSearch.setBackgroundResource(R.drawable.btn_done_background); txtSearchLabel.setText(R.string.btn_done_text); txtSearch.setVisibility(View.VISIBLE); txtSearch.requestFocus(); } else { btnManage.setVisibility(View.VISIBLE); txtManageLabel.setVisibility(View.VISIBLE); btnBrowse.setVisibility(View.VISIBLE); txtBrowseLabel.setVisibility(View.VISIBLE); btnRefresh.setVisibility(View.VISIBLE); txtRefreshLabel.setVisibility(View.VISIBLE); btnSearch.setBackgroundResource(R.drawable.btn_search_background); txtSearchLabel.setText(R.string.btn_search_text); txtSearch.setVisibility(View.GONE); txtSearch.setText(""); loadData(null, true, false, false); } break; default: break; } }
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; } }
private void setTaskName() { EditText taskName = getTaskNameComponent(); taskName.setText(task.getString(TaskAdapter.TASK_NAME, "")); }
public void clear() { inputView.setText(""); listAdapter.clear(); listAdapter.notifyDataSetChanged(); }