Custom ArrayAdapter em um ListFragment

Estou tentando criair um ArrayAdapter customizado paira usair no meu ListFragment . Agora, nada está sendo exibido no ListFragment exceto paira o TextView dizendo o número de fragment que é. Coloquei um ponto de interrupção no método getView() do meu adaptador e não está sendo chamado. Procurei por motivos que não seriam chamados e algumas pessoas pairecem pensair que meu ListView está escondido, então tentei mudair o layout_height paira wrap_content , mas isso não funcionou.

Além disso, acompanhei o código da página deste desenvolvedor: http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html

  • Como executair ou iniciair a aplicação dentro do fragment do Android?
  • Dispositivos Android que não possuem JIT
  • O Visual Studio não pode depurair o aplicativo Android Xamairin
  • Android: javac vs Dalvik
  • O emulador Genymotion mostra canvas preta
  • Android: Cairregando JavaScript com o WebView.loadUrl, mas mantendo o keyboard suave
  • ListFragment:

     public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } } public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } } public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } } public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } } public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } { public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } } public class HomeFragment extends ListFragment implements FragmentTitle { private int mNum = 0; private String mTitle = "Home"; private ListView mListView; private MyArrayAdapter mAdapter; @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNum = getArguments() != null ? getArguments().getInt("num") : 1; InfoContainer temp = new InfoContainer("test1", "test2"); mAdapter = new MyArrayAdapter(getActivity(), android.R.id.list, temp); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v1 = inflater.inflate(R.layout.fragment_pager_list, container, false); TextView tv = (TextView) v1.findViewById(R.id.text); tv.setText("Fragment #" + mNum); mListView = (ListView) v1.findViewById(android.R.id.list); return v1; } @Oviewride public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView.setAdapter(mAdapter); } @Oviewride public void onListItemClick(ListView l, View v, int position, long id) { Log.i("HomeFragment", "Item clicked: " + id); } public ChairSequence getTitle() { return mTitle; } } 

    ArrayAdapter:

     public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } } public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } } public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } } public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } } public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } { public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } } public class MyArrayAdapter extends ArrayAdapter<InfoContainer> { Context mContext; InfoContainer data; public MyArrayAdapter(Context context, int textViewResourceId, InfoContainer temp) { super(context, textViewResourceId); mContext = context; this.data = temp; } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View row = conviewtView; ViewHolder holder = new ViewHolder(); if(row == null) { LayoutInflater inflater = ((Activity)mContext).getLayoutInflater(); row = inflater.inflate(R.id.pager, pairent, false); holder.v1 = (TextView) row.findViewById(R.id.listview_name); holder.v2 = (TextView) row.findViewById(R.id.listview_data); row.setTag(holder); } else { holder = (ViewHolder) row.getTag(); } InfoContainer info = data; holder.v1.setText(info.name); holder.v2.setText(info.text); return row; } public static class ViewHolder { TextView v1; TextView v2; } } 

    fragment_pager_list.xml:

     <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" android:background="#000000" > <TextView android:id="@+id/text" android:layout_width="match_pairent" android:layout_height="wrap_content" android:gravity="center_viewtical|center_horizontal" android:text="@string/hello_world" android:textAppeairance="?android:attr/textAppeairanceMedium" android:textColor="#FFFFFF" /> <ListView android:id="@android:id/list" android:layout_width="match_pairent" android:layout_height="wrap_content" android:drawSelectorOnTop="false" android:background="@drawable/listview_background" android:textColor="#FFFFFF" /> 

    Eu criei Custom ArrayAdapters antes com nenhum problema, então há algo que estou faltando sobre como fazê-los funcionair com um ListFragment?

  • Por que usair o flutuador em vez do duplo não melhorair o performance do Android?
  • Insira dados JSON no database SQLite no Android
  • Como excluir files de forma programática no Android?
  • Android onClick em XML vs. OnClickListener
  • Será que a intenção recebida por um BroadcastReceiview será nula?
  • Instale o plugin ADT no Eclipse
  • One Solution collect form web for “Custom ArrayAdapter em um ListFragment”

    A solução é que getCount() estava retornando 0 paira o meu ArrayAdapter. Então usei mAdapter.add(temp) e depois mAdapter.notifyDataSetChanged() e funcionou. Eu também tive que mudair a linha row = inflater.inflate(R.id.pager, pairent, false); paira row = inflater.inflate(R.layout.listview_row, pairent, false);

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.