GridView:
- Contains a horizontally scrolling list of View objects, also often used with image icons; the user can select an item to perform some action upon.
Let's take Simple Example which shows the Grid of TextView that will be display as grid on Screen and you can select on of them.
The Layout of this app is as follows : main.xml
<?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridView01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnWidth="90dp" android:numColumns="2" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="columnWidth" android:gravity="center" />
The Java file can be as follows.
package com.container; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.GridView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class GridViewContainerActivity extends Activity { /** Called when the activity is first created. */ GridView gv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String [] colors= {"Red","Green","Blue","Pink","Gray"}; gv=(GridView)findViewById(R.id.gridView01); ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_gallery_item, colors); gv.setAdapter(adapter); gv.setNumColumns(3); gv.setBackgroundColor(Color.CYAN); gv.setGravity(Gravity.CENTER); gv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> myAdapter, View view, int myItemId, long myLang) { // TODO Auto-generated method stub String selectedItem=gv.getItemAtPosition(myItemId).toString(); Toast.makeText(getApplicationContext(), selectedItem, 2).show(); } }); } }
When you first run your app that will shown as follows.
This comment has been removed by the author.
ReplyDeleteKocaeli
ReplyDeleteDenizli
Bartın
Kocaeli
Adana
6ASTB
Antalya
ReplyDeleteKonya
Adana
Ankara
Van
2ZJ
Erzurum
ReplyDeleteElazığ
Konya
Zonguldak
Eskişehir
021
Adana
ReplyDeleteElazığ
Kayseri
Şırnak
Antep
3İ2Jİ
ankara
ReplyDeletesakarya
tekirdağ
kastamonu
amasya
VL0GW
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
J120Cİ
Antep Lojistik
ReplyDeleteYalova Lojistik
Erzincan Lojistik
Tekirdağ Lojistik
Elazığ Lojistik
1N8
DA96E
ReplyDeleteBalıkesir Parça Eşya Taşıma
Kırklareli Parça Eşya Taşıma
Tunceli Evden Eve Nakliyat
İstanbul Evden Eve Nakliyat
Uşak Parça Eşya Taşıma
6636B
ReplyDeleteSpotify Takipçi Satın Al
Coin Nasıl Çıkarılır
Tesla Coin Hangi Borsada
Binance Referans Kodu
Kripto Para Madenciliği Nedir
Discord Sunucu Üyesi Satın Al
Qlc Coin Hangi Borsada
Yeni Çıkacak Coin Nasıl Alınır
Threads Beğeni Satın Al
BE7A5
ReplyDeletedebank
pancakeswap
trezor suite
phantom wallet
pancakeswap
uniswap
dexscreener
sushiswap
bscpad