我的layout 里有好几个edittext,启动起来后,点击第一个edittext获得焦点,也显示光标,弹出了软键盘,可以输入,完了按软键盘上的回车键,第二个edittext不能获得焦点,但是软键盘仍然还显示,第二个edittext也不显示光标。求哪位高人指教!
        <LinearLayout
          style="@style/setup_wizard_layout_margin"
          android:id="@+id/feedback"
          android:orientation="vertical"
          android:background="@drawable/table_bg"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:visibility="visible">                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="15dp"
                    android:background="@drawable/text_bg"
                    android:orientation="vertical"
                    android:gravity="center">
                    <LinearLayout
                        android:orientation="horizontal"
                        android:focusable="true"
                        android:focusableInTouchMode="true"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content">
                        <TextView
                            android:id="@+id/question_class"
                            android:layout_width="200dip"
                            android:layout_height="wrap_content"
                            android:text="@string/feedback_choose_catogry"
                            style="@style/common_body_text1"
                            android:gravity="left"/>
                        <Spinner
                            android:layout_gravity="left"
                            android:id="@+id/spinner"
                            android:gravity="center"
                            android:layout_width="200dp"
                            android:layout_height="50dp"/>
                    </LinearLayout>
                        
                        <LinearLayout
                            android:orientation="horizontal"
                            android:layout_marginTop="5dp"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content">
                            <TextView
                                android:id="@+id/name"
                                style="@style/common_body_text1"
                                android:layout_width="200dip"
                                android:layout_height="wrap_content"
                                android:text="@string/feedback_submit_name"
                                android:gravity="left"/>
                            <EditText
                                android:id="@+id/name_edit"
                                android:layout_width="0dip"
                                android:layout_height="50dp"
                                android:layout_weight="1"
                                android:background="@drawable/dialog_table_bg"
                                style="@style/common_body_text"
                                android:singleLine="true"
                                android:hint="@string/feedback_submit_name_hit"/>
                            </LinearLayout>
                            
                            <LinearLayout
                            android:orientation="horizontal"
                            android:focusable="true"
                            android:focusableInTouchMode="true"
                            android:layout_marginTop="5dp"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content">
                            <TextView
                                android:id="@+id/tel"
                                style="@style/common_body_text1"
                                android:layout_width="200dip"
                                android:layout_height="wrap_content"
                                android:text="@string/feedback_submit_tel"
                                android:gravity="left"/>
                            <EditText
                                android:id="@+id/tel_edit"
                                android:background="@drawable/dialog_table_bg"
                                style="@style/common_body_text"
                                android:inputType="number"
                                android:layout_width="0dip"
                                android:layout_weight="1"
                                android:layout_height="wrap_content"
                                android:singleLine="true"
                                android:hint="@string/feedback_submit_tel_hint"/>
                            </LinearLayout>
                            
                             <LinearLayout
                                android:orientation="horizontal"
                                android:focusable="true"
                                android:focusableInTouchMode="true"
                                android:layout_marginTop="5dp"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/contact"
                                    style="@style/common_body_text1"
                                    android:layout_width="200dip"
                                    android:layout_height="wrap_content"
                                    android:text="@string/feedback_submit_mail"
                                    android:gravity="left"/>
                                <EditText
                                    android:background="@drawable/dialog_table_bg"
                                    style="@style/common_body_text"
                                    android:id="@+id/contact_edit"
                                    android:layout_width="0dip"
                                    android:layout_weight="1"
                                    android:layout_height="wrap_content"
                                    android:singleLine="true"
android:hint="@string/feedback_submit_mail_hint"/>
                               </LinearLayout>
                                
                               <LinearLayout
                                android:orientation="horizontal"
                                android:layout_width="fill_parent"
                                android:layout_marginTop="5dp"
                                android:layout_height="110dp"
                                android:focusable="true"
                                android:focusableInTouchMode="true">
                                <TextView
                                    android:id="@+id/question"
                                    style="@style/common_body_text1"
                                    android:layout_width="200dip"
                                    android:layout_height="wrap_content"
                                    android:text="@string/feedback_submit_content"
                                    android:gravity="left"/>
                                <EditText
                                    android:id="@+id/pick_up_massage"
                                    style="@style/common_body_text"
                                    android:background="@drawable/dialog_table_bg"
                                    android:layout_weight="1"
                                    android:layout_width="0dip"
                                    android:layout_height="110dip"
                                    android:gravity="top"
                                    android:scrollbars="vertical"
                                    android:hint="@string/edittext_message"
                                    android:maxLength="300"/>
                                </LinearLayout>
                                
                                <LinearLayout
                                android:orientation="horizontal"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="10dp"
                                android:gravity="center">
                                
                                <Button
                                    style="@style/common_button_text"
                                    android:background="@drawable/btn_bg"
                                    android:id="@+id/feedback_send_btn"
                                    android:text="@string/send"
                                    android:gravity="center"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginRight="10dp"/>
                                
                                <Button
                                    style="@style/common_button_text"
                                    android:background="@drawable/btn_bg"
                                    android:id="@+id/feedback_save_btn"
                                    android:text="@string/feedback_save"
                                    android:gravity="center"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginLeft="10dp"/>
                                
                                </LinearLayout>
                    </LinearLayout>
        </LinearLayout>androidedittext

解决方案 »

  1.   

    监听焦点name_edit.setOnFocusChangeListener(focusListener);OnFocusChangeListener focusListener = new OnFocusChangeListener(){
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus){
                switch(v.getId()){
                    case R.id.name_edit:
                    //....  
                        break;
                    //....  
                    }用下面的函数设置新焦点。setFocusable(true);
    requestFocus();
    setFocusableInTouchMode(true);