在一个片段上,我有类似的布局
问题.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
谢谢