Import android os. Bundle


public ImagePagerAdapter(Context context, int[] imageIds) {


Download 141 Kb.
Pdf ko'rish
bet12/15
Sana20.11.2023
Hajmi141 Kb.
#1789524
1   ...   7   8   9   10   11   12   13   14   15
Bog'liq
Qodirov mobil ilovakar 2 dedline

 
public ImagePagerAdapter(Context context, int[] imageIds) { 
this.context = context; 
this.imageIds = imageIds; 

 
@Override 
public int getCount() { 
return imageIds.length; 

 
@NonNull 
@Override 
public Object instantiateItem(@NonNull ViewGroup container, int position) { 
LayoutInflater inflater = (LayoutInflater) 
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View itemView = inflater.inflate(R.layout.pager_item, container, false); 
 
ImageView imageView = itemView.findViewById(R.id.imageView); 
imageView.setImageResource(imageIds[position]); 
 
container.addView(itemView); 


 
return itemView

 
@Override 
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object 
object) { 
container.removeView((View) object); 

 
@Override 
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { 
return view == object; 


 
res/layout/pager_item.xml: 
 

android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 
 

android:id="@+id/imageView" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 

Download 141 Kb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling