Friday, August 13, 2021
Country Details a2z
Country Description 2
Main Activity.Java: (Java)
package com.jrliton.countrydetailsa2z;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private ListView listViewIdM1;
private String[] country_names;
private int[] flags = {R.drawable.af, R.drawable.al, R.drawable.dz, R.drawable.ad, R.drawable.ao,
R.drawable.ag, R.drawable.ar, R.drawable.am, R.drawable.au, R.drawable.at, R.drawable.az,
// 11...
R.drawable.bs, R.drawable.bh, R.drawable.bd, R.drawable.bb, R.drawable.by, R.drawable.be,
R.drawable.bz, R.drawable.bj, R.drawable.bt, R.drawable.bo, R.drawable.ba, R.drawable.bw,
R.drawable.br, R.drawable.bn, R.drawable.bg, R.drawable.bf, R.drawable.bi,
// 17...
R.drawable.cv, R.drawable.kh, R.drawable.cm, R.drawable.ca, R.drawable.cf, R.drawable.td,
R.drawable.cl, R.drawable.cn, R.drawable.co, R.drawable.km, R.drawable.cg, R.drawable.ck,
R.drawable.cr, R.drawable.hr, R.drawable.cu, R.drawable.cy, R.drawable.cz,
// 18...
R.drawable.kp, R.drawable.cd, R.drawable.dk, R.drawable.dj, R.drawable.dm, R.drawable.do_,
// 6...
R.drawable.ec, R.drawable.eg, R.drawable.sv, R.drawable.gq, R.drawable.er, R.drawable.ee,
R.drawable.sz, R.drawable.et,
// 8
R.drawable.fo, R.drawable.fj, R.drawable.fi, R.drawable.fr,
// 4
R.drawable.ga, R.drawable.gm, R.drawable.ge, R.drawable.de, R.drawable.gh, R.drawable.gr,
R.drawable.gd, R.drawable.gt, R.drawable.gn, R.drawable.gw, R.drawable.gy,
// 11
R.drawable.ht, R.drawable.hn, R.drawable.hu,
// 3
R.drawable.is, R.drawable.in, R.drawable.id, R.drawable.ir, R.drawable.iq, R.drawable.ie,
R.drawable.il, R.drawable.it,
// 8
R.drawable.jm, R.drawable.jp, R.drawable.jo,
// 3
R.drawable.kz, R.drawable.ke, R.drawable.ki, R.drawable.kw, R.drawable.kg,
// 5
R.drawable.la, R.drawable.lv, R.drawable.lb, R.drawable.ls, R.drawable.lr, R.drawable.ly,
R.drawable.lt, R.drawable.lu, R.drawable.mg, R.drawable.mw, R.drawable.my, R.drawable.mv,
R.drawable.ml, R.drawable.mt, R.drawable.mh, R.drawable.mr, R.drawable.mu, R.drawable.mx,
R.drawable.fm, R.drawable.mc, R.drawable.mn, R.drawable.me, R.drawable.ma, R.drawable.mz,
R.drawable.mm,
// 25
R.drawable.na, R.drawable.nr, R.drawable.np, R.drawable.nl, R.drawable.nz, R.drawable.ni,
R.drawable.ne, R.drawable.ng, R.drawable.nu, R.drawable.mk, R.drawable.no,
// 11
R.drawable.om,
// 1
R.drawable.pk, R.drawable.pw, R.drawable.pa, R.drawable.pg, R.drawable.py, R.drawable.pe,
R.drawable.ph, R.drawable.pl, R.drawable.pt,
// 9
R.drawable.qa,
// 1
R.drawable.kr, R.drawable.md, R.drawable.ro, R.drawable.ru, R.drawable.rw,
// 5
R.drawable.kn, R.drawable.lc, R.drawable.vc, R.drawable.ws, R.drawable.sm, R.drawable.st,
R.drawable.sa, R.drawable.sn, R.drawable.rs, R.drawable.sc, R.drawable.sl, R.drawable.sg,
R.drawable.sk, R.drawable.si, R.drawable.sb, R.drawable.so, R.drawable.za, R.drawable.ss,
R.drawable.es, R.drawable.lk, R.drawable.sd, R.drawable.sr, R.drawable.sr, R.drawable.ch,
R.drawable.sy,
// 25
R.drawable.tj, R.drawable.th, R.drawable.tl, R.drawable.tg, R.drawable.tk, R.drawable.to,
R.drawable.tt, R.drawable.tn, R.drawable.tr, R.drawable.tm, R.drawable.tv,
// 11
R.drawable.ug, R.drawable.ua, R.drawable.ae, R.drawable.gb, R.drawable.tz, R.drawable.us,
R.drawable.uy, R.drawable.uz,
// 8
R.drawable.vu, R.drawable.ve, R.drawable.vn,
// 3
R.drawable.ye,
// 1
R.drawable.zm, R.drawable.zw,
// 2
// R.drawable., R.drawable., R.drawable., R.drawable., R.drawable., R.drawable.,
// R.drawable., R.drawable., R.drawable., R.drawable., R.drawable., R.drawable.,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
country_names = getResources().getStringArray(R.array.country_names);
listViewIdM1 = findViewById(R.id.listViewIdM1);
CustomAdapter adaptor = new CustomAdapter(this,country_names,flags);
listViewIdM1.setAdapter(adaptor);
listViewIdM1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view, int position, long id) {
String value = country_names[position];
Intent myintent = new Intent(MainActivity.this, ProfileActivity.class);
myintent.putExtra("countrydescription",value);
startActivity(myintent);
//Toast.makeText(MainActivity.this,value,Toast.LENGTH_LONG).show();
}
});
}
}
Custom Adapter: (Java)
package com.jrliton.countrydetailsa2z;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class CustomAdapter extends BaseAdapter {
int[] flags;
String[] country_names;
Context context;
private LayoutInflater inflater;
CustomAdapter(Context context, String[]country_names, int[] flags){
this.context=context;
this.country_names=country_names;
this.flags=flags;
}
@Override
public int getCount() {
return country_names.length;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView==null){
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.sample_view,parent,false);
}
ImageView imageView = convertView.findViewById(R.id.countryImageId0);
TextView textView = convertView.findViewById(R.id.countryNameId0);
imageView.setImageResource(flags[position]);
textView.setText(country_names[position]);
return convertView;
}
}
Profile Activity: (Java)
package com.jrliton.countrydetailsa2z;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ProfileActivity extends AppCompatActivity {
private TextView profileTextViewId;
private ImageView afnature;
private String[] country_profile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
profileTextViewId = findViewById(R.id.profileTextViewId);
afnature = findViewById(R.id.afnature);
String pValue = getIntent().getExtras().getString("countrydescription");
if (pValue.equals("Afganistan")){
profileTextViewId.setText(getResources().getString(R.string.af_description));
afnature.setImageResource(R.drawable.afgnature);
}
else if (pValue.equals("Albania")){
profileTextViewId.setText(getResources().getString(R.string.al_description));
}
else if (pValue.equals("Algeria")){
profileTextViewId.setText(getResources().getString(R.string.dg_description));
}
else if (pValue.equals("Andorra")){
profileTextViewId.setText(getResources().getString(R.string.ad_description));
}
}
}
Activity_Main.Xml: (Layout)
Sample View: (Layout)
Activity_Profile.Xml: (Layout)
String.Xml 1 : (Values)
Country Details a2z
- Afganistan
// af
- Albania
// al
- Algeria
//dz
- Andorra
// ad
- Angola
// ao
- Antigua and Barbuda
// ag
- Argentina
// ar
- Armenia
// am
- Australia
// au
- Austria
// at
- Azerbaijan
// az
// 11
- Bahamas
// bs
- Bahrain
// bh
- Bangladesh
// bd
- Barbados
// bb
- Belarus
// by
- Belgium
// be
- Belize
// bz
- Benin
// bj
- Bhutan
// bt
- Bolivia
// bo
- Bosnia and Herzegovina
// ba
- Botswana
// bw
- Brazil
// br
- Brunei Darussalam
// bn
- Bulgaria
// bg
- Burkina Faso
// bf
- Burundi
// bi
// 17
- Cabo Verde
// cv
- Cambodia
// kh
- Cameroon
// cm
- Canada
// ca
- Central African Republic
// cf
- Chad
// td
- Chile
// cl
- China
// cn
- Colombia
// co
- Comoros
// km
- Congo
// cg
- Cook Islands
// ck
- Costa Rica
// cr
- Croatia
// hr
- Cuba
// cu
- Cyprus
// cy
- Czechia
// cz
// 17
- Democratic People s Republic of Korea
// kp
- Democratic Republic of the Congo
// cd
- Denmark
// dk
- Djibouti
// dj
- Dominica
// dm
- Dominican Republic
// do_
// 6
- Ecuador
//ec
- Egypt
//eg
- El Salvador
//sv
- Equatorial Guinea
//gq
- Eritrea
//er
- Estonia
//ee
- Eswatini
//sz
- Ethiopia
//et
// 8
- Faroe Islands
//fo
- Fiji
//fj
- Finland
//fi
- France
//fr
// 4
- Gabon
//ga
- Gambia
//gm
- Georgia
//ge
- Germany
//de
- Ghana
//gh
- Greece
//gr
- Grenada
//gd
- Guatemala
//gt
- Guinea
//gn
- Guinea Bissau
//gw
- Guyana
//gy
// 11
- Haiti
//ht
- Honduras
//hn
- Hungary
//hu
// 3
- Iceland
//is
- India
//in
- Indonesia
//id
- Iran Islamic Republic of Iran
//ir
- Iraq
//iq
- Ireland
//ie
- Israel
//il
- Italy
//it
// 8
- Jamaica
//jm
- Japan
//jp
- Jordan
//jo
// 3
- Kazakhstan
//kz
- Kenya
//ke
- Kiribati
//ki
- Kwait
//kw
- Kyrgyzstan
//kg
// 5
- Laos
//la
- Latvia
//lv
- Lebanon
//lb
- Lesotho
//ls
- Liberia
//lr
- Libya
//ly
- Lithuania
//lt
- Luxembourg
//lu
- Madagascar
//mg
- Malawi
//mw
- Malaysia
//my
- Maldives
//mv
- Mali
//ml
- Malta
//mt
- Marshall Islands
//mh
- Mauritania
//mr
- Mauritius
//mu
- Mexico
//mx
- Micronesia Federated States of Micronesia
//fm
- Monaco
//mc
- Mongolia
//mn
- Montenegro
//me
- Morocco
//ma
- Mozambique
//mz
- Myanmar
//mm
// 25
- Namibia
//na
- Nauru
//nr
- Nepal
//np
- Netherlands
//nl
- New Zealand
//nz
- Nicaragua
//ni
- Niger
//ne
- Nigeria
//ng
- Niue
//nu
- North Mecedonia
//mk
- Norway
//no
// 11
- Oman
//om
// 1
- Pakistan
//pk
- Palau
//pw
- Panama
//pa
- Papua New Guinea
//pg
- Paraguay
//py
- Peru
//pe
- Philippines
//ph
- Poland
//pl
- Portugal
//pt
// 9
- Qatar
//qa
// 1
- Republic of Korea
//kr
- Republic of Moldova
md
- Romania
//ro
- Russian Federation
//ru
- Rwanda
//rw
// 5
- Saint Kitts and Nevis
//kn
- Saint Lucia
//lc
- Saint Vincent and the Grenadines
//vc
- Samoa
//ws
- San Marino
//sm
- Sao Tome and Principe
//st
- Saudi Arabia
//sa
- Senegal
//sn
- Serbia
//rs
- Seychelles
//sc
- Sierra Leone
//sl
- Singapore
//sg
- Slovakia
//sk
- Slovenia
//si
- Solomon Islands
//sb
- Somalia
//so
- South Africa
//za
- South Sudan
//ss
- Spain
//es
- Sri Lanka
//lk
- Sudan
//sd
- Suriname
//sr
- Sweden
//se
- Switzerland
//ch
- Syrian Arab Republic
//sy
// 25
- Tajikistan
//tj
- Thiland
//th
- Timor-Leste
//tl
- Togo
//tg
- Tokelau
//tk
- Tonga
//to
- Trinidad and Tobago
//tt
- Tunisia
//tn
- Turkey
//tr
- Turkmenistan
//tm
- Tuvalu
//tv
// 11
- Uganda
//ug
- Ukraine
//ua
- United Arab Emirates
//ae
- United Kingdom of Great Britain and Northern Ireland
//gb
- United Republic of Tanzania
//tz
- United States of America
//us
- Uruguay
//uy
- Uzbekistan
//uz
// 8
- Vanuatu
//vu
- Venezuela Bolivarian Republic of Venezuela
//ve
- Vietnam
//vn
// 3
- Yemen
//ye
// 1
- Zambia
//zm
- Zimbabwe
//zw
// 2
String.XMl 2 : (Values)
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Albenia is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Afghanistan is a beautiful country.\n
Algeria is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Andora is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Albenia is a beautiful country.\n
Angola is a beautiful country.\n
Angola is a beautiful country.\n
Angola is a beautiful country.\n
Angola is a beautiful country.\n
Angola is a beautiful country.\n
Manifest:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment