5

1つのフラグメントで、次のようなレイアウトがあります

質問.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/question"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="44dp"
    android:layout_marginTop="47dp"
    android:text="TextView" />

<CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/question"
    android:layout_marginLeft="85dp"
    android:layout_toRightOf="@+id/question"
    android:text="CheckBox" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/question"
    android:layout_marginTop="23dp"
    android:ems="10"
    android:inputType="text" />

</RelativeLayout>

私はこのようなインターフェースを持っています

ここに画像の説明を入力

しかし問題は、私が集中しEditTextてそこに何かを書き込もうとしても、何も起こらないことです。テキストが表示されず、キーボードが表示されません。クリックしたままにするとEditText、何も貼り付けられないというメッセージが表示されます。テキストの編集にテキストが入力されないのはなぜですか?

これが私のコードです

public class ListFrag extends ListFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {  
        super.onActivityCreated(savedInstanceState);       
        setListAdapter(new ListFragAdapter(
            new MyListData("Software Engineer", "Basit", "4 years"),
            new MyListData("Lt. Commander", "Kashif", "12 years"),
            new MyListData("Beautiful", "Hafsa", "23 years"),
            new MyListData("Electrical Engineer", "Wajahat", "7 years"),
            new MyListData("Doctor", "Mehreen", "12 years")));  
    } //end of onActivityCreated()

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {        
        MyListData listData = (MyListData)getListAdapter().getItem(position);       
        DetailFrag frag = (DetailFrag) getFragmentManager().findFragmentById(R.id.frag_capt);
        if (frag != null && frag.isInLayout()) {            
            getData(position, listData, frag);  
        }

    } //end of onListItemClick()

    private void getData(int position, MyListData listData, DetailFrag frag) {      
        String artist = listData.artist;
        String title = listData.title;      
        frag.setText(artist, title);        
    } //end of getData()

} //end of class ListFrag

これが私の詳細フラグメントです

public class DetailFrag extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        
        View view = inflater.inflate(R.layout.question , container, false);
        return view;

    } //end of onCreateView()

    public void setText(String artist, String title) {

        TextView leftSide_artist = (TextView) getView().findViewById(R.id.question);
        leftSide_artist.setText(artist);
        
    } //end of setText()

} //end of class DetailFrag

ありがとう

4

2 に答える 2

0

はい、違いがあります。通常、Landscap モードでキーボードが AVD にポップアップしませんが、デバイスでは正常に動作します。これをどのように管理したか

  • エミュレーターの [設定] >> [言語とキーボード] に移動し、すべての辞書と自動提案をオフにします
  • AVD Manger に移動し、AVD を編集します。[ハードウェア] セクションで [新規] をクリックし、[キーボード サポート] を追加します。
  • AVDを再起動

それがあなたのために働くかどうか試してください

于 2012-09-03T12:08:08.680 に答える