O'rnatish bo'yicha ko'rsatmalar Ilovani mobil qurilmangizda oching va quyidagilarni bajaring: Antiparkon botini Telegram-ga qanday ulash va telefon raqamini topish mumkin?
Download 1.28 Mb.
|
11-18 labaratoriya
Laboratoriya ishi №18
Mavzu: Android Studio platformasida foydalanuvchi grafik interfeysini yaratish (Slider yaratish) Tashqi ko'rinishida Slider standart Seekbarga o'xshaydi. Ammo kichik farqlar mavjud. Ularni ko'rish uchun men oddiy loyihani chizdim. Keling, ekranga bir nechta slayderni, tugmachani qo'shamiz va komponentning harakatini ko'rib chiqamiz. Men kutubxonaning so'nggi versiyasidan foydalandim. implementation 'com.google.android.material:material:1.2.0-alpha06' android:layout_height="wrap_content"> android:layout_width="match_parent" android:layout_height="200dp" android:layout_alignParentTop="true" /> android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="bottom" android:padding="10dip" app:centered="true" app:fillColor="#df0623" app:pageColor="#fff" app:snap="false" /> public class ImageSlider { private String name; //optional @DrawableRes @DrawableRes private int resId; public ImageSlider(String name, int resId) { this.name = name; this.resId = resId; } @Override public String toString() { return name; } //getters and setters } public class ImageSliderAdapter extends PagerAdapter { private Context mContext; private List private LayoutInflater inflater; public ImageSliderAdapter(Context context, List mContext = context; imageList = list; inflater = LayoutInflater.from(context); } @Override public Object instantiateItem(ViewGroup collection, int position) { ViewGroup imageLayout = (ViewGroup) inflater.inflate(R.layout.slider_home, collection, false); ((ImageView) imageLayout.findViewById(R.id.imageView)).setImageResource(imageList.get(position).getResId()); collection.addView(imageLayout); return imageLayout; } @Override public void destroyItem(ViewGroup collection, int position, Object view) { collection.removeView((View) view); } @Override public int getCount() { return CustomPagerEnum.values().length; } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public CharSequence getPageTitle(int position) { return imageList.get(position).getName(); } } Sizning e'tiboringizni tortadigan birinchi narsa, biz slider.values orqali bir nechta slayderlarni o'rnatishimiz mumkin. Ular o'zlarini mustaqil tutadilar va bir-biriga aralashmaydilar. Ikkinchi slayder android:stepSize atributi orqali diskret rejimga o'rnatiladi. Siz ushbu rejimda trekda kichik nuqtalar paydo bo'lganini sezishingiz mumkin. Agar siz slayderni bossangiz, tepada joriy qiymatni ko'rsatadigan plastinka paydo bo'ladi. Tugmani bosish slayderni dasturli ravishda birinchi slayderdagi kerakli joyga o'rnatadi. E'tibor bering, bizning holatlarimizda komponent bitta slayder bilan qovoq slayderiga aylanadi, chunki biz qiymatlar ro'yxatini qayta o'rnatdik va faqat bittasini qoldirdik. Slider da bir nechta tinglovchilar mavjud. Namoyish uchun men ulardan birini olib keldim - Slider.OnSliderTouchListener. Plastinkadagi matnni o'zgartirish mumkin. Bu katta raqamlardan foydalanilganda foydali bo'ladi. Keyin ko'p sonli nolga ega raqamlar o'rniga (million, trillion va boshqalar) qisqartirilgan versiyalardan foydalanishingiz mumkin. LabelFormatter interfeysi bu xatti-harakat uchun javobgardir. BasicLabelFormatter yordamchi interfeysi ham mavjud bo'lib, unda 9100 o'rniga 9,1K kabi foydali ko'p sonli yorliqlar mavjud. Keling, bir oz o'ynaymiz va uch harfli so'z yozamiz. slider2.setLabelFormatter { "Кот" } Download 1.28 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling