We will see here how to create a alphabet ABC learning app for kids. Basically I have targeted use of this alphabet app for 2, 3 or 4 year old babies. Kids like to learn with pictures, animations and sound effect. I will explain all necessary ideas, concepts to build this babies learning app.
The most important thing is that it is basic app and we will learn how to use Navigation Drawer Activity, AlertDialog, LayoutInflater, ImageView, MediaPlayer and you can add your own features, future development in code.
MainActivity.java:
Select Navigation Drawer Activity while creating project. See the image :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
package com.cacompadda.alphabetapp; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.view.View; import android.support.design.widget.NavigationView; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); } @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); /* if (id == R.id.nav_camera) { // Handle the camera action } else if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { }*/ if(id==R.id.alphabet){ Intent i =new Intent(this,Alphabet.class); startActivity(i); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } } |
comment on default code from line no. 84 to 96 and create your own class like Alphabet.class(we will discuss later). Intent used here to open or start Activity. The method startActivity(i) is used here to launch a activity(Alphabet.class).
Open activity_main_drawer.xml and edit the code like :
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/alphabet" android:icon="@drawable/ic_menu_gallery" android:title="Alphabet Introduction" /> </group> </menu> |
You will get this file in res\menu\ directory.
Put your all images of alphabet in drawable folder. Create new folder with name raw inside res directory . Put your all .mp3 format sounds of alphabet inside raw folder. You can find all pronunciation like ‘A for Apple’ including images and .mp3 on internet. If you don’t have then I will provide you after end of this post.
Alphabet.java:
Whne user click on ‘Alphabet Indroduction’ from Navigation Drawer thin this activity will open.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
package com.cacompadda.alphabetapp; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class Alphabet extends Activity implements View.OnClickListener { Button a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z; MediaPlayer ourSong; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alphabet_main); a=(Button)findViewById(R.id.a); b=(Button)findViewById(R.id.b); c=(Button)findViewById(R.id.c); d=(Button)findViewById(R.id.d); e=(Button)findViewById(R.id.e); f=(Button)findViewById(R.id.f); g=(Button)findViewById(R.id.g); h=(Button)findViewById(R.id.h); i=(Button)findViewById(R.id.i); j=(Button)findViewById(R.id.j); k=(Button)findViewById(R.id.k); l=(Button)findViewById(R.id.l); m=(Button)findViewById(R.id.m); n=(Button)findViewById(R.id.n); o=(Button)findViewById(R.id.o); p=(Button)findViewById(R.id.p); q=(Button)findViewById(R.id.q); r=(Button)findViewById(R.id.r); s=(Button)findViewById(R.id.s); t=(Button)findViewById(R.id.t); u=(Button)findViewById(R.id.u); v=(Button)findViewById(R.id.v); w=(Button)findViewById(R.id.w); x=(Button)findViewById(R.id.x); y=(Button)findViewById(R.id.y); z=(Button)findViewById(R.id.z); a.setOnClickListener(this); b.setOnClickListener(this); c.setOnClickListener(this); d.setOnClickListener(this); e.setOnClickListener(this); f.setOnClickListener(this); g.setOnClickListener(this); h.setOnClickListener(this); i.setOnClickListener(this); j.setOnClickListener(this); k.setOnClickListener(this); l.setOnClickListener(this); m.setOnClickListener(this); n.setOnClickListener(this); o.setOnClickListener(this); p.setOnClickListener(this); q.setOnClickListener(this); r.setOnClickListener(this); s.setOnClickListener(this); t.setOnClickListener(this); u.setOnClickListener(this); v.setOnClickListener(this); w.setOnClickListener(this); x.setOnClickListener(this); y.setOnClickListener(this); z.setOnClickListener(this); } public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater factory; View view; ImageView image; switch (v.getId()){ case R.id.a: ourSong=MediaPlayer.create(this,R.raw.a); ourSong.start(); builder.setTitle("A"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.a); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.b: ourSong=MediaPlayer.create(this,R.raw.b); ourSong.start(); builder.setTitle("B"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.b); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.c: ourSong=MediaPlayer.create(this,R.raw.c); ourSong.start(); builder.setTitle("C"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.c); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.d: ourSong=MediaPlayer.create(this,R.raw.d); ourSong.start(); builder.setTitle("D"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.d); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.e: ourSong=MediaPlayer.create(this,R.raw.e); ourSong.start(); builder.setTitle("E"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.e); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.f: ourSong=MediaPlayer.create(this,R.raw.f); ourSong.start(); builder.setTitle("F"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.f); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.g: ourSong=MediaPlayer.create(this,R.raw.g); ourSong.start(); builder.setTitle("G"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.g); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.h: ourSong=MediaPlayer.create(this,R.raw.h); ourSong.start(); builder.setTitle("H"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.h); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.i: ourSong=MediaPlayer.create(this,R.raw.i); ourSong.start(); builder.setTitle("I"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.i); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.j: ourSong=MediaPlayer.create(this,R.raw.j); ourSong.start(); builder.setTitle("J"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.j); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.k: ourSong=MediaPlayer.create(this,R.raw.k); ourSong.start(); builder.setTitle("K"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.k); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.l: ourSong=MediaPlayer.create(this,R.raw.l); ourSong.start(); builder.setTitle("L"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.l); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.m: ourSong=MediaPlayer.create(this,R.raw.m); ourSong.start(); builder.setTitle("M"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.m); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.n: ourSong=MediaPlayer.create(this,R.raw.n); ourSong.start(); builder.setTitle("N"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.n); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.o: ourSong=MediaPlayer.create(this,R.raw.o); ourSong.start(); builder.setTitle("O"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.o); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.p: ourSong=MediaPlayer.create(this,R.raw.p); ourSong.start(); builder.setTitle("P"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.p); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.q: ourSong=MediaPlayer.create(this,R.raw.q); ourSong.start(); builder.setTitle("Q"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.q); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.r: ourSong=MediaPlayer.create(this,R.raw.r); ourSong.start(); builder.setTitle("R"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.r); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.s: ourSong=MediaPlayer.create(this,R.raw.s); ourSong.start(); builder.setTitle("S"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.s); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.t: ourSong=MediaPlayer.create(this,R.raw.t); ourSong.start(); builder.setTitle("T"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.t); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.u: ourSong=MediaPlayer.create(this,R.raw.u); ourSong.start(); builder.setTitle("U"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.u); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.v: ourSong=MediaPlayer.create(this,R.raw.v); ourSong.start(); builder.setTitle("V"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.v); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.w: ourSong=MediaPlayer.create(this,R.raw.w); ourSong.start(); builder.setTitle("W"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.w); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.x: ourSong=MediaPlayer.create(this,R.raw.x); ourSong.start(); builder.setTitle("X"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.x); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.y: ourSong=MediaPlayer.create(this,R.raw.y); ourSong.start(); builder.setTitle("Y"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.y); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; case R.id.z: ourSong=MediaPlayer.create(this,R.raw.z); ourSong.start(); builder.setTitle("Z"); factory = LayoutInflater.from(Alphabet.this); view = factory.inflate(R.layout.a, null); image= (ImageView) view.findViewById(R.id.ai); image.setImageResource(R.drawable.z); builder.setView(view); builder.setNeutralButton("BACK", null); builder.show(); break; } } } |
Here MediaPlayer class can be used to control playback of audio/video files and streams. Here start() method used to start the audio/video file. You will get detail information here.
AlertDialog.Builder Creates a builder for an alert dialog that uses the default alert dialog theme. There are some methods like setTitle(), show() to create and design Alert Dialog.(Here the official doc).
LayoutInflater class instantiates a layout XML file into its corresponding View
objects.(See Here).
alphabet_main.xml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="match_parent" android:weightSum="2" android:background="@drawable/cacomplogo" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/a13" android:layout_weight="1" android:layout_marginLeft="10dp"> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="A" android:id="@+id/a" android:background="#0b90f6" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="B" android:id="@+id/b" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="C" android:id="@+id/c" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="D" android:id="@+id/d" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="E" android:id="@+id/e" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="F" android:id="@+id/f" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="G" android:id="@+id/g" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="H" android:id="@+id/h" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="I" android:id="@+id/i" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="J" android:id="@+id/j" android:background="#0b90f6" android:layout_marginTop="15dp"/> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="K" android:id="@+id/k" android:background="#0b90f6" android:layout_marginTop="15dp"/> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="L" android:id="@+id/l" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="M" android:id="@+id/m" android:background="#0b90f6" android:layout_marginTop="15dp"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:orientation="vertical" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/b13" android:paddingLeft="295dp"> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="N" android:id="@+id/n" android:background="#0b90f6" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="O" android:id="@+id/o" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="P" android:id="@+id/p" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="Q" android:id="@+id/q" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="R" android:id="@+id/r" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="S" android:id="@+id/s" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="T" android:id="@+id/t" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="U" android:id="@+id/u" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="V" android:id="@+id/v" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="W" android:id="@+id/w" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="X" android:id="@+id/x" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="Y" android:id="@+id/y" android:background="#0b90f6" android:layout_marginTop="15dp" /> <Button android:layout_width="35dp" android:layout_height="35dp" android:text="Z" android:id="@+id/z" android:background="#0b90f6" android:layout_marginTop="15dp" /> </LinearLayout> </LinearLayout> |
When user click on button of alphabet then AlertDialog will open with image and sound. The output you can see like this:
In this way you can create a simple app for your kids and babies. You can download the code and resources from Here. If you have any question regarding this post then you can comment below.
thank for your tutorial about this. I’m use alphabet learning theme for my college assignment.
i’m still don’t understand about your :
view = factory.inflate(R.layout.a, null);
image= (ImageView) view.findViewById(R.id.ai);
where is R.id.ai location?
and R.layout.a ?