Skip to main content

SPAN in Android TableLayout

Finally after two days of hard work, I managed to solve the layout issue. Having to insert the AdMob ads in dictionary app, I need to do minor changes to the layout. This morning I realised that there should be a SPAN capability in the TableLayout (as similar to HTML table). I decided to give it a try and, Alhamdulillah it works.

 

SPAN in Android TableLayout

What is SPAN in table? It is a capability to merge several cells in a table. If it is a column span, than it is merging several columns in a row. In this example, I managed to merge 2 cells in a row (in line 21) and and 3 cells in a row (refer to line 85 in the code below).

 

     

Column span 2

 
     
     
     

Column span 3

 

And this is the XML code for the layout.

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
   3:     android:orientation="vertical"
   4:     android:background="@drawable/bd"
   5:     android:layout_width="fill_parent"
   6:     android:layout_height="fill_parent"
   7:     android:stretchColumns="1"
   8:        >
   9:     <TableRow>
  10:         <TextView android:text="Perkataan Melayu" 
  11:             android:textColor="#ffffff"
  12:             android:layout_width="fill_parent" 
  13:             android:layout_height="wrap_content" />
  14:     </TableRow>
  15:     <TableRow>
  16:         <EditText android:text="" 
  17:             android:layout_column="0"
  18:             android:id="@+id/txtmelayu" 
  19:             android:layout_width="fill_parent" 
  20:             android:layout_height="wrap_content"
  21:             android:layout_span="2" />
  22:         <Button android:text="Cari" 
  23:             android:layout_column="2"
  24:             android:id="@+id/btncari" 
  25:             android:layout_width="wrap_content" 
  26:             android:layout_height="wrap_content" />
  27:     </TableRow>>
  28:     <TableRow>    
  29:             <TextView android:text="Bahasa Inggeris papar di sini" 
  30:             android:id="@+id/tveng" 
  31:             android:textColor="#ffffff"
  32:             android:layout_width="wrap_content" 
  33:             android:layout_height="wrap_content" />
  34:             
  35:             <Button android:text="" 
  36:             android:layout_column="2" 
  37:             android:drawableLeft="@drawable/sound"
  38:             android:id="@+id/btnsebutan1" 
  39:             android:layout_width="wrap_content" 
  40:             android:layout_height="wrap_content" 
  41:             />
  42:     </TableRow>
  43:     <TableRow>
  44:         <TextView android:text="Bahasa Arab papar di sini" 
  45:             android:id="@+id/tvarab" 
  46:             android:textColor="#ffffff"
  47:             android:layout_width="wrap_content" 
  48:             android:layout_height="wrap_content" />
  49:             <Button android:text="" 
  50:             android:layout_column="2" 
  51:             android:drawableLeft="@drawable/sound"
  52:             android:id="@+id/btnsebutan" 
  53:             android:layout_width="wrap_content" 
  54:             android:layout_height="wrap_content" 
  55:             />
  56: </TableRow>
  57:     <LinearLayout android:gravity="center_horizontal">
  58:                 <Button android:text="Muat turun imej" 
  59:                android:id="@+id/btndownimej" 
  60:             android:layout_width="wrap_content" 
  61:             android:layout_height="wrap_content" 
  62:              />
  63:     </LinearLayout>
  64:     <TableRow android:gravity="center_horizontal">
  65:         <ImageView 
  66:         android:id="@+id/image1"
  67:         android:layout_width="100sp"
  68:         android:layout_height="100sp"
  69:         />
  70:     </TableRow>
  71:     <TableRow>
  72:         <TextView android:text=" " 
  73:             android:textColor="#ffffff"
  74:             android:layout_width="fill_parent" 
  75:             android:layout_height="wrap_content" />
  76:     </TableRow>
  77:     <TableRow android:gravity="center_horizontal">
  78:         <com.google.ads.AdView
  79:             xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
  80:             android:id="@+id/adView1"
  81:             android:layout_width="wrap_content"
  82:             android:layout_height="wrap_content"
  83:             ads:adSize="BANNER"
  84:             ads:adUnitId="CHANGE_TO_YOUR_ADMOB_PUBLISHER_ID"
  85:             android:layout_span="3"
  86:             />
  87:     </TableRow>
  88: </TableLayout>

 

ScreenHunter_07 May. 19 09.43Autobot, ROLL-OUT!!!

Comments

Popular posts from this blog

Several English proverbs and the Malay pair

Or you could download here for the Malay proverbs app – https://play.google.com/store/apps/details?id=net.kerul.peribahasa English proverbs and the Malay pair Corpus Reference: Amir Muslim, 2009. Peribahasa dan ungkapan Inggeris-Melayu. DBP, Kuala Lumpur http://books.google.com.my/books/about/Peribahasa_dan_ungkapan_Inggeris_Melayu.html?id=bgwwQwAACAAJ CTRL+F to search Proverbs in English Definition in English Similar Malay Proverbs Definition in Malay 1 Where there is a country, there are people. A country must have people. Ada air adalah ikan. Ada negeri adalah rakyatnya. 2 Dry bread at home is better than roast meat home's the best hujan emas di negeri orang,hujan batu di negeri sendiri Betapa baik pun tempat orang, baik lagi tempat sendiri. 3 There's no accounting for tastes We can't assume that every people have a same feel Kepala sama hitam hati lain-lain. Dalam kehidupan ini, setiap insan berbeza cara, kesukaan, perangai, tabia

Submit your blog address here

Create your own blog and send the address by submitting the comment of this article. Make sure to provide your full name, matrix and URL address of your blog. Refer to the picture below. Manual on developing a blog using blogger.com and AdSense, download here … Download Windows Live Writer (a superb offline blog post editor)

Contact Us at blog.kerul.net

Powered by EMF HTML Contact Form

ASK kerul pls...

Ask me please, just click the button... Any question related to the web, PHP, database, internet, this blog, my papers, or anything. I'll answer to you as soon as I can, if related to my domain. If not I'll try to find out from Google and provide you a link that can help you solve a problem. Sincerely, kerul. ASK kerul pls... http://kerul.blogspot.com

The Challenges of Handling Proverbs in Malay-English Machine Translation – a research paper

*This paper was presented in the 14th International Conference on Translation 2013 ( http://ppa14atf.usm.my/ ). 27 – 29 August 2013, Universiti Sains Malaysia, Penang. The PDF version is here: www.scribd.com/doc/163669571/Khirulnizam-The-Challenges-of-Automated-Detection-and-Translation-of-Malay-Proverb The test data is here: http://www.scribd.com/doc/163669588/Test-Data-for-the-Research-Paper-the-Challenges-of-Handling-Proverbs-in-Malay-English-Machine-Translation Khirulnizam Abd Rahman, Faculty of Information Science & Technology, KUIS Abstract: Proverb is a unique feature of Malay language in which a message or advice is not communicated indirectly through metaphoric phrases. However, the use of proverb will cause confusion or misinterpretation if one does not familiar with the phrases since they cannot be translated literally. This paper will discuss the process of automated filtering of Malay proverb in Malay text. The next process is translation. In machine translatio