In this Example we show how to Add Multiple View in the Single Row of the ListView Control. We take two Controls ImageView and TextView as Shown follows.
- First We Create the layout file for the following that is as fllows : res/layout/rawlayout.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content" android:src="@drawable/icon" /> <TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1" android:layout_marginLeft="10px" android:layout_marginTop="10px" android:textSize="20px" ></TextView> </LinearLayout>
- Then We Create The Custom ArrayAdapter Class Which will create by extending ArrayAdapter Class that has a getView() method that use to set how we want customize our row layout of for each raw of ListView
package com.container; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class MyArrayAdapter extends ArrayAdapter<String> { Context context; String[] values; public MyArrayAdapter(Context context, String[] values) { super(context, R.layout.rowlayout, values); this.context = context; this.values = values; } public View getView(int positon, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.rowlayout, parent, false); TextView textView = (TextView) rowView.findViewById(R.id.textView1); ImageView image = (ImageView) rowView.findViewById(R.id.imageView1); textView.setText(values[positon]); if (positon % 2 == 0) { image.setImageResource(R.drawable.yes); } else { image.setImageResource(R.drawable.no); } return rowView; } }
- Then We create the Our Activity Class which extends the ListActivity class in which we have set the Adapter of using the method setListAdapter() which has an argument of our own MyArrayAdapter class instance.
package com.container; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.widget.ListView; import android.widget.Toast; public class MultipleViewListActivity extends ListActivity{ String [] values= {"Android", "iPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2"};; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new MyArrayAdapter(getApplicationContext(), values)); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), values[position], 5).show(); //super.onListItemClick(l, v, position, id); } }
Mardin
ReplyDeleteistanbul
Çanakkale
Antep
Elazığ
HX223
Eskişehir
ReplyDeleteAdana
Sivas
Kayseri
Samsun
Uİ8X2
https://titandijital.com.tr/
ReplyDeletebalıkesir parça eşya taşıma
eskişehir parça eşya taşıma
ardahan parça eşya taşıma
muş parça eşya taşıma
7G3YB
kocaeli evden eve nakliyat
ReplyDeletekilis evden eve nakliyat
bursa evden eve nakliyat
trabzon evden eve nakliyat
hakkari evden eve nakliyat
CQ0ST
E2AD8
ReplyDeleteÇerkezköy Mutfak Dolabı
Kırıkkale Parça Eşya Taşıma
Gümüşhane Evden Eve Nakliyat
Referans Kimliği Nedir
Kars Şehirler Arası Nakliyat
Keçiören Parke Ustası
Elazığ Parça Eşya Taşıma
Nevşehir Lojistik
İzmir Şehirler Arası Nakliyat
4E92E
ReplyDeleteIsparta Evden Eve Nakliyat
buy fat burner
Kütahya Evden Eve Nakliyat
trenbolone enanthate
masteron
clenbuterol for sale
order trenbolone enanthate
Kripto Para Borsaları
buy deca durabolin
D4A06
ReplyDeleteKırıkkale Şehirler Arası Nakliyat
Mardin Şehir İçi Nakliyat
Probit Güvenilir mi
Ünye Organizasyon
Adıyaman Şehirler Arası Nakliyat
Bitranium Coin Hangi Borsada
Van Evden Eve Nakliyat
Tokat Lojistik
Çerkezköy Marangoz
BE380
ReplyDeletemanisa canlı ücretsiz sohbet
tekirdağ sesli sohbet sesli chat
bitlis sohbet
tunceli görüntülü canlı sohbet
canlı sohbet bedava
çorum görüntülü sohbet odaları
aksaray bedava sohbet
mobil sohbet chat
canlı sohbet odaları
A9000
ReplyDeletedefillama
dappradar
dexscreener
satoshi
poocoin
pancakeswap
eigenlayer
metamask
ledger desktop
BEC3B
ReplyDeleteBuharkent
Altınova
Polatlı
Pazarlar
Sultandağı
Konya
İdil
Güneysu
Çiftlikköy
92DA12366D
ReplyDeletetiktok düşmeyen takipçi