I'am having EditText in my application which is to display DatePicker. I'am seeing the keyboard when i click the EditText and if i again click the EditText strongly then my DatePicker is coming. I don't want to show the keyboard to the user. How can i achieve this scenario?
This is my code.
dataandtime = new EditText(getActivity());
dataandtime.setLayoutParams(params1);
dataandtime.setWidth(1000);
dataandtime.setTextAppearance(context, android.R.style.TextAppearance_Medium);
dataandtime.setHint("Set Date and Time");
dataandtime.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
TimePickerDialog tpd = new TimePickerDialog(context, mTimeSetListener, mhour, mminute, false);
tpd.show();
DatePickerDialog dpd = new DatePickerDialog(context,
mDateSetListener, myear, mmonth, mday);
dpd.show();
}
});
您可以在适当的背景下使用TextView
To set your EditText only numeric use this in your Java:
dataandtime.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL);
or this in your XML:
android:inputType="number"
To disable the keyboard, try this in your activity's declaration in ManifestFile:
<activity
android:name=".YourActivity"
...
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.