Guruh talabasi Abdiyev Husniddin Adapter bo‘yicha qo‘llanma Android Studioda misol


Maxsus adapter SimpleAdapter-ni quyidagicha kengaytiradi


Download 1.52 Mb.
bet4/6
Sana24.12.2022
Hajmi1.52 Mb.
#1059102
1   2   3   4   5   6
Bog'liq
ikkThU3JL2PtvpQdAhw1K9PkoBTZJi-x

Maxsus adapter SimpleAdapter-ni quyidagicha kengaytiradi:
public class CustomAdapter extends SimpleAdapter {
public CustomAdapter(Context context, List> data, int resource, String[] from, int[] to) {
super(context, data, resource, from, to);

}

@Override


public View getView(int position, View convertView, ViewGroup parent) {
return super.getView(position, convertView, parent);

}

@Override


public int getCount() {
return super.getCount();
}
}
Oddiy adapterning yuqoridagi bekor qilingan funksiyalari allaqachon Custom SimpleAdapter maqolasida tasvirlangan.
Android Studioda adapterga misol:
Quyida Android-da adapterdan foydalanishni ko‘rsatadigan Android Studio misoli keltirilgan. Ushbu misolda biz SimpleAdapter-dan foydalangan holda mevalar nomlari ro‘yxatini tasvirlar bilan ko‘rsatamiz va foydalanuvchi har safar ro‘yxat elementini bosganda, meva nomi tostda ko‘rsatiladi. Quyida toʻliq Android Studio kodini yuklab olishingiz, yakuniy natijani koʻrishingiz va bosqichma-bosqich tushuntirishni oʻqishingiz mumkin:
1-qadam: Yangi loyiha yarating va uni SimpleAdapterExample deb nomlang.
2-qadam: res -> layout -> xml (yoki) main.xml ni oching va quyidagi kodni qo‘shing:
Ushbu bosqichda biz xml faylini ochamiz va uning turli atributlaridan foydalangan holda ListViewni ko‘rsatish uchun kodni qo‘shamiz.
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

android:id="@+id/simpleListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#000"
android:dividerHeight="2dp"
android:listSelector="#600"/>



Download 1.52 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




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