I'm building a PrefenceFragment but I've a problem to inflate a custom layout within the fragment. Pratically, I created a custom layout to inflate but doesn't works (the layout was not inflated). I'm trying some solutions but I don't understand where I wrong...
This is my sample code:
public class MyPreferenceFragment extends PreferenceFragment
{
private ListView listjob;
@Override
public void onCreate(final Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
View viewlist = inflater.inflate(R.layout.pref_listview_job, null);
TextView txtProva = (TextView)viewlist.findViewById(R.id.txtProva);
txtProva.setText("This is a text");
}
}
This is my custom layout pref_listview_job.xml
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtProva"/>
</LinearLayout>
Thanks!