Android : Hide the soft keyboard when click the EditView

ChocolateCake

New Member
In my application , I have to get date from the user . First I use one button . When the user clicks the button one dialog box will appear which holds datepicker. And get the result in one TextView. Now I want to replace the button by EditView. On Clicking the EditView, That Dialog Box Will have to appear and no keyboards will appear.\[code\]@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.report); EmployeeGlobal eg=(EmployeeGlobal)getApplicationContext(); String uid=eg.getMainUserId(); ArrayList<String>list=eg.getAllProjects(uid); Spinner spinner = (Spinner)findViewById(R.id.all_projs); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerArrayAdapter); Toast.makeText(getApplicationContext(), "Report"+uid, Toast.LENGTH_LONG).show(); mStartDateDisplay=(TextView)findViewById(R.id.strdate); mEndDateDisplay = (TextView) findViewById(R.id.enddate); mEndDate = (Button) findViewById(R.id.end_dateb); mStartDate=(Button)findViewById(R.id.start_dateb); mYear=c1.get(Calendar.YEAR); mMonth = c1.get(Calendar.MONTH); mDay = c1.get(Calendar.DAY_OF_MONTH); mStartDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub showDialog(DATE_DIALOG_START); //updateDisplay(mStartDateDisplay); } }); mEndDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub showDialog(DATE_DIALOG_END); //updateDisplay(mEndDateDisplay); } }); } private void updateDisplay(TextView T) { T.setText( new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("-") .append(mDay).append("-") .append(mYear).append(" ")); } private DatePickerDialog.OnDateSetListener mFromDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(mStartDateDisplay); } }; private DatePickerDialog.OnDateSetListener mToDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mYear = year; mMonth = monthOfYear; mDay = dayOfMonth; updateDisplay(mEndDateDisplay); } }; @Override protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_END: return new DatePickerDialog(this,mToDateSetListener, mYear, mMonth, mDay); case DATE_DIALOG_START: return new DatePickerDialog(this,mFromDateSetListener,mYear, mMonth, mDay); } return null; }\[/code\]So please anyone help me to right method.
 
Back
Top