ビューページャー(スライダー)のフラグメントで編集テキストを作成したい。ここで、DetailFragment2.java で既に行ったこと:
public View onCreateView(LayoutInflater inflater,
Bundle savedInstanceState) {
LayoutInflater inflater2 = getActivity().getLayoutInflater();
aView = inflater2.inflate(R.layout.details2, null);
EditText notatki = (EditText) aView.findViewById(R.id.editText1);
//notatki = (EditText) getView().findViewById(R.id.editText1);
SharedPreferences settings = this.getActivity().getSharedPreferences("PREFS", 0);
notatki.setText(settings.getString("value", "raz dwa trzy"));
return notatki;
}
そしてdetails2.xmlで
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#00000000"
android:ems="10"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
</RelativeLayout>
そして、そのビューに edittext フィールドが表示されません。私は何を間違っていますか?
私はそのように変更しましたが、うまくいきました。助けてくれてありがとう:
View view = inflater.inflate(R.layout.details2, container, false);
EditText notatki = (EditText) view.findViewById(R.id.editText1);
SharedPreferences settings = this.getActivity().getSharedPreferences("PREFS", 0);
notatki.setText(settings.getString("value", "raz dwa trzy"));
return view;