ViewPager no muestra nada
Estoy crear paginador de vista con el adaptador de paginador de vista personalizada pero cuando ejecuto el proyecto no puedo ver nada
public class CustomAdapter extends PagerAdapter { private List<NewsObject> newsObjects; private Activity mActivity; private LayoutInflater inflater; private ImageLoaderConfiguration imageConfig; private ImageLoader imageLoader = ImageLoader.getInstance(); public CustomAdapter(List<NewsObject> newsObjects, Activity mActivity) { super(); Log.d("Con :", "structor"); this.newsObjects = newsObjects; this.mActivity = mActivity; imageConfig = new ImageLoaderConfiguration.Builder( mActivity.getApplicationContext()).build(); imageLoader.init(imageConfig); } @Override public int getCount() { return this.newsObjects.size(); } @Override public void destroyItem(View collection, int position, Object view) { ((ViewPager) collection).removeView((View) view); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { ImageViewPlus img_news_image; TextView txt_news_title; TextView txt_news_description; inflater = (LayoutInflater) mActivity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.detail_news_page, null); img_news_image = (ImageViewPlus) viewLayout .findViewById(R.id.img_detail_news_image); txt_news_title = (TextView) viewLayout .findViewById(R.id.txt_detail_news_title); txt_news_description = (TextView) viewLayout .findViewById(R.id.txt_detail_news_description); Log.d("TAG :", "instantiateItem"); imageLoader.displayImage(newsObjects.get(position).getNews_image(), img_news_image); Toast.makeText(mActivity.getApplicationContext(), Constantz.newsObjects.get(position).getNews_id() + "", Toast.LENGTH_SHORT).show(); txt_news_title.setText(newsObjects.get(position).getNews_title()); txt_news_description.setText(newsObjects.get(position) .getNews_description()); return viewLayout; } }
Pero el brindis está mostrando pero no puedo ver ningún texto en mi aplicación
- ¿Hay una manera de determinar si es posible llamar a un dialog.dismiss () sin vacío try-catch bloque?
- Retrofit + método POST + www-form-urlencoded
- Gson con nombre dinámico (Android)
- Abra la cámara nativa de Android con OpenCV
- La actividad se bloquea en setAdapter (ArrayAdapter);
- onDowngrade () en SQLiteOpenHelper (u otra forma de no bloquearse al degradar)
- SetContentView (R.layout.main); error
- Appcompat res values-v21 Los errores de themes_base en eclipse no desaparecen
- Cómo ajustar el tamaño de los desplegables de azulejos
- Hacer un bucle de audio en Android
- Cómo obtener datos de cordova-plugin-nativestorage en android java
- Java / Android HttpURLConnection setChunkedStreamingMode no funciona con todos los servidores PHP
- ¿Cómo configurar el formato de 24 horas para la fecha en java?
escribir
container.addView(viewLayout);
Antes de devolver la vista en instantiateItem
public Object instantiateItem(ViewGroup container, int position) { ImageViewPlus img_news_image; TextView txt_news_title; TextView txt_news_description; inflater = (LayoutInflater) mActivity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View viewLayout = inflater.inflate(R.layout.detail_news_page, null); img_news_image = (ImageViewPlus) viewLayout .findViewById(R.id.img_detail_news_image); txt_news_title = (TextView) viewLayout .findViewById(R.id.txt_detail_news_title); txt_news_description = (TextView) viewLayout .findViewById(R.id.txt_detail_news_description); Log.d("TAG :", "instantiateItem"); imageLoader.displayImage(newsObjects.get(position).getNews_image(), img_news_image); Toast.makeText(mActivity.getApplicationContext(), Constantz.newsObjects.get(position).getNews_id() + "", Toast.LENGTH_SHORT).show(); txt_news_title.setText(newsObjects.get(position).getNews_title()); txt_news_description.setText(newsObjects.get(position) .getNews_description()); container.addView(viewLayout); return viewLayout; }
Te has olvidado de añadir tu opinión al contenedor. Necesita agregar antes de devolver su vista.
((ViewPager) container).addView(viewLayout);
También seguro que usted ha fijado el artículo actual para el paginador de la visión.
No está agregando su vista al contenedor.
container.addView(viewLayout, 0);
<TabHost ...... <TabWidget ..... <FrameLayout android:id="@android:id/tabcontent" android:layout_width="0dp" android:layout_height="0dp" > </FrameLayout> <android.support.v4.view.ViewPager
- ¿Cómo ignorar el error y continuar la corriente infinita?
- Cómo iniciar correctamente la actividad de PostExecute en Android?