แป้นพิมพ์ไม่แสดง

พูดง่ายๆ:

A ViewPager ใน FragmentActivity โดยมี 4 Fragments

A TextView ในรูปแบบเหนือ ViewPager ภายนอก Fragments

ฉัน "เพิ่ม" Fragment แทนที่เค้าโครงของ Fragment อื่น:

getSupportFragmentManager()
    .beginTransaction()
    .add(R.layout.activity, fragmentToPush)
    .addToBackStack("1")
    .commit();

ฉันทำความสะอาดกองหลัง:

getSupportFragmentManager()
    .popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

หลังจากนั้นแป้นพิมพ์จะไม่แสดงอีกต่อไปเมื่อกด Textview มีโฟกัส แต่คีย์บอร์ดไม่ไป

แก้ไข :

TextView ไม่สามารถโฟกัสได้อยู่แล้วหลังจาก "เพิ่ม" ฉันใช้ AutoCompleteTextView

ฉันกำลังทำอะไรกับมัน:

    mSearchAutoCompletion = (AutoCompleteTextView)
        mIncludeSearchLayout.findViewById(R.id.search_text);

        mSearchAutoCompletion.addTextChangedListener(new 
        TextWatcher() {... // nothing more with the textview

        mSearchAutoCompletion.setOnEditorActionListener(new
        OnEditorActionListener() {... // nothing more with the textview

แก้ไข 2 : เค้าโครง (ฉันใช้ รวม):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_home_layout_search"
    android:layout_width="match_parent"
    android:layout_height="@dimen/edit_text"
    android:background="@drawable/gradient_banner_inverse" >

    <ImageButton
        android:id="@+id/search_button"
        android:layout_width="@dimen/edit_text"
        android:layout_height="@dimen/edit_text"
        android:layout_alignParentLeft="true"
        android:adjustViewBounds="true"
        android:background="@drawable/selector_blue"
        android:padding="2dp"
        android:scaleType="centerInside"
        android:src="@drawable/search" />

    <AutoCompleteTextView
        android:id="@+id/search_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="1px"
        android:layout_marginRight="1px"
        android:layout_marginTop="1px"
        android:layout_toRightOf="@+id/search_button"
        android:background="@android:color/white"
        android:focusableInTouchMode="true"
        android:hint="@string/search_hint"
        android:imeOptions="actionSearch"
        android:inputType="text"
        android:paddingLeft="@dimen/margin_medium"
        android:paddingRight="@dimen/margin_medium"
        android:singleLine="true"
        android:textColor="@color/clr_dark_grey" />

    <ImageButton
        android:id="@+id/search_cross"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="1px"
        android:layout_marginRight="1px"
        android:layout_marginTop="1px"
        android:background="@android:color/white"
        android:src="@android:drawable/ic_menu_close_clear_cancel"
        android:visibility="gone" />

</RelativeLayout>

จากนั้น include :

<include
    android:id="@+id/activity_search"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/edit_text"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="@dimen/margin_large"
    android:layout_marginRight="@dimen/margin_large"
    android:layout_marginTop="@dimen/margin_large"
    layout="@layout/view_search" />

แก้ไข 3: ฉันพยายามแสดงแป้นพิมพ์ด้วยตนเอง

mSearchAutoCompletion.setOnClickListener(this);

case R.id.search_text:
                InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                inputMethodManager.toggleSoftInputFromWindow(mSearchAutoCompletion.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
                break;
  • ตอนแรกฉันเลือกช่องข้อความ มันแสดงแล้วซ่อนคีย์บอร์ดอย่างรวดเร็ว (แปลก)
  • เมื่อฉันเพิ่มส่วนต่างๆ แป้นพิมพ์ก็โอเค
  • เมื่อฉันลบส่วนต่างๆ แป้นพิมพ์จะไม่ตอบสนองอีกต่อไป
  • ฉันเพิ่มส่วนอีกครั้ง แป้นพิมพ์ก็ใช้ได้อีกครั้ง

person An-droid    schedule 24.06.2014    source แหล่งที่มา
comment
คุณใช้การอ้างอิงทั้งหมดของ textview ภายใน oncreateView หรือไม่   -  person Illegal Argument    schedule 24.06.2014
comment
มุมมองข้อความเป็นแบบ fonctionnal อย่างสมบูรณ์ ฉันได้รับมุมมองใน onCreateview และฉันตั้งค่าผู้ฟังใน onViewCreated   -  person An-droid    schedule 24.06.2014
comment
สิ่งที่ฉันมักจะทำคือทำให้ตัวแปรระดับคลาส textview เริ่มต้นได้ใน oncreateview ใช้ใน onStart และฉันใช้เฉพาะ popBackStackImmediate() วิธีนี้ได้ผลสำหรับฉันมาโดยตลอดและมันทำความสะอาดแบ็คสแต็ก ลองใช้ .popBackStackImmediate(1, FragmentManager.POP_BACK_STACK_INCLUSIVE)   -  person Illegal Argument    schedule 24.06.2014
comment
ฉันแก้ไขคำถาม ฉันเสียสมาธิหลังจากเพิ่ม/แทนที่ และฉันใช้ AutoCompleteTextView   -  person An-droid    schedule 24.06.2014
comment
กรุณาเพิ่มรหัสเพิ่มเติม รหัสที่ใช้ textview ฉันเดาว่า textview ไม่ได้ถูกกำหนดไว้ในกิจกรรมหรือส่วนที่มีตัวแสดงของคุณ แต่อยู่ภายในส่วนใดส่วนหนึ่ง   -  person Illegal Argument    schedule 24.06.2014
comment
ไม่ TextView ถูกกำหนดไว้ในกิจกรรมและใช้ภายในกิจกรรมเท่านั้น ฉันแก้ไขคำถาม   -  person An-droid    schedule 24.06.2014
comment
บางทีคุณอาจโพสต์ XML เลย์เอาต์ให้เราได้ไหม   -  person Tash Pemhiwa    schedule 24.06.2014
comment
@ Yume117 เหตุใดจึงมี 2 AutoCompleteTextView พร้อมด้วย @+id/search_text เดียวกัน ??   -  person Bhavin Chauhan    schedule 01.07.2014
comment
stackoverflow.com/questions/3109516/   -  person Bhavin Chauhan    schedule 01.07.2014
comment
@ bhavin-chauhan วางสำเนาไม่ถูกต้อง   -  person An-droid    schedule 01.07.2014
comment
@ Yume117 เวอร์ชัน Android ของคุณคือ 4.2.2 ?   -  person duggu    schedule 03.07.2014
comment
ฉันทดสอบบน Nexus 4 (android 4.4.4) บน galaxy s3 (android 4.3) บน asus nexus 7 (android 4.4.2) มันเหมือนกันทุกที่   -  person An-droid    schedule 03.07.2014
comment
คุณยังไม่ได้ลองใช้ .popBackStackImmediate(1, ...) ใช่ไหม มันไม่ชัดเจนหากคุณทำหรือไม่จากโพสต์ของคุณ   -  person RoraΖ    schedule 03.07.2014
comment
ฉันทำ. กล่าวไว้ในตอนต้น. แต่หลังจากนั้นฉันก็บอกว่าปัญหาเกิดขึ้นก่อนที่ฉันจะแตกแฟรกเมนต์ด้วยซ้ำ   -  person An-droid    schedule 03.07.2014