2013-11-12 6 views
0

Я хочу сделать отредактированный текст фрагментом моего пейджера представления (слайдера). Вот то, что я сделал уже в моем DetailFragment2.java:Simple EditText in Fragment

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; 

ответ

1

Ваш Редактировать текст есть, но вы просто установить прозрачный фон, так что вы не можете видеть это.

android:background="#00000000" 

у вас есть 4 пары нулей, так что формат AARRGGBB первый AA - нули в вашем случае - устанавливает alpha = 0 поэтому фон полностью прозрачным.

пытаются установить фон на # RR0000 или просто использовать RRGGBB формат (# 000000)

EDIT поскольку не помогли устранить проблему, попробуйте обновить так, как вы надуть макет

public View onCreateView(LayoutInflater inflater, ViewGroup parent, 
     Bundle savedInstanceState) { 

aView = inflater.inflate(R.layout.details2, parent, false); 
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;  
} 

следующие две строки являются наиболее важными:

public View onCreateView(LayoutInflater inflater, ViewGroup parent, 
       Bundle savedInstanceState) { 

и

aView = inflater.inflate(R.layout.details2, parent, false); 
+0

Нет, его там нет. Я пытаюсь сделать это, как сказал, но все же я ничего не вижу –

+0

только что отредактировал мой ответ. надеюсь, на этот раз это поможет. – fgeorgiew