1

这是我的片段类:

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;
}

当 Fragment 加载,并且选择了 EDitText (Lat) (Get Focused) 时,不显示 KeyBoard。如何显示键盘?

4

1 回答 1

0

添加这一行:

Lat.clearFocus();

紧接在该行之后:

Lat = (EditText) InflaterView.findViewById(R.id.LatitudeEdit); 
于 2013-01-22T00:15:57.583 回答