这是我的片段类:
public class PrayerTimes extends Fragment {
EditText Lat;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
InflaterView = inflater.inflate(R.layout.activity_prayer_times, container, false);
Lat = (EditText) InflaterView.findViewById(R.id.LatitudeEdit);
Lat.addTextChangedListener(new TextWatcher()
{
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
// TODO Auto-generated method stub
}
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
return InflaterView;
}
当片段加载时,选择EDitText(Lat)(Get Focused)时,不会显示KeyBoard。如何展示KeyBoard?
答案 0 :(得分:0)
添加以下行:
Lat.clearFocus();
紧接在该行之后:
Lat = (EditText) InflaterView.findViewById(R.id.LatitudeEdit);