Exibição de lista no fragmento não funciona
Heres meu código de fragmento:
public class LeftFragment extends ListFragment {
ArrayList<String> data;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.left_fragment, container, false);
data = new ArrayList<String>();
data.add("1. dell");
data.add("2. samsung");
data.add("3. apple");
data.add("4. hp");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, data);
setListAdapter(adapter);
return view;
}
e heres meu xml para este fragmento:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FF0000" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Heres the list :"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
e
logcat file says :Binary XML file line #5:error inflating class fragment !!
o que meu projeto tem é: dois fragmentos para a esquerda e para a direita. à esquerda, um deve conter o modo de exibição de lista,
mas wat eu hav observado é fragmentos estão funcionando bem quando eu não uso "ListView" em xml !! mas como eu estou usando, o fragmento esquerdo também está ocupando o espaço do fragmento direito.
Por favor ajude ! obrigado !