tablelayout inside linearlayout android..;p

this example for all viewer and reader tablelayout inside on linearlayout. the linearlayout give you border side..;]

pertanyaan.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@color/pertanyaan_bac"
  android:padding="20dip">
  
	<LinearLayout 
	android:id="@+id/backgroundtengah" 
	android:layout_width="fill_parent" 
	android:layout_height="wrap_content"
	android:background="@color/background"
	android:orientation="vertical">
		
		<TableLayout 
		android:id="@+id/TableLayout01" 
		android:layout_width="match_parent" 
		android:layout_height="match_parent">
		
			<!-- disini tempat array string soal -->
			<TableRow>		
				<TextView 
				android:text="@string/nomersoal" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>	
			
				<TextView 
				android:text="@string/soal" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			
			<!-- disini tempat array string jawaban -->
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			

				<CheckBox 
				android:text="@string/A" 
				android:id="@+id/CheckBox01" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>		
				
			</TableRow>
				<!-- jawaban b -->
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
				
				<CheckBox 
				android:text="@string/B" 
				android:id="@+id/CheckBox02" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
				<!-- jawaban C -->
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
				
				<CheckBox 
				android:text="@string/C" 
				android:id="@+id/CheckBox02" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
				<!-- jawaban D -->
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
				
				<CheckBox 
				android:text="@string/D" 
				android:id="@+id/CheckBox02" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
				<!-- jawaban E -->
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
				
				<CheckBox 
				android:text="@string/E" 
				android:id="@+id/CheckBox02" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			
			<!-- jeda -->		
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			<TableRow>
				<TextView 
				android:text="@string/kosongfieldtable" 
				android:id="@+id/nomersoal" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"/>
			</TableRow>
			<!-- jeda end -->	
		</TableLayout>	
		<TableLayout 
		android:id="@+id/TableLayout02" 
		android:layout_width="match_parent" 
		android:layout_height="match_parent">
			<TableRow >
				<Button 
				android:padding="3dip" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content" 
				android:id="@+id/PREV" 
				android:text="@string/PREV"/>
				
				<Button 
				android:text="@string/NEXT" 
				android:layout_width="wrap_content" 
				android:layout_height="wrap_content"
				android:id="@+id/NEXT"
				android:padding="3dip" />	
			
</TableRow>
		</TableLayout>
	</LinearLayout>

</LinearLayout>

string.xml

<string name="nomersoal">1</string>
<string name="soal">Apakah yang dimaksud dengan tanaman berbiji? pililah satu dari beberapa jawaban berikut?</string>
<string name="kosongfieldtable"></string>
<string name="A">jawaban1</string>
<string name="B">jawaban2</string>
<string name="C">jawaban3</string>
<string name="D">jawaban4</string>
<string name="E">jawaban5</string>
<string name="NEXT">NEXT&gt;&gt;</string>
<string name="PREV">&lt;&lt;PREV</string>

color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#ffff0000</color>
<color name="pertanyaan_bac">#ffffffff</color>
</resources>

call layout

package tanya.jawab2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
public class Pilihansoal extends ListActivity{
public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pertanyaan);
}

androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="tanya.jawab2"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".tanyanya"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
		<activity android:name=".Pilihansoal"></activity>
</application>
    <uses-sdk android:minSdkVersion="9" />

</manifest> 

result:

One thought on “tablelayout inside linearlayout android..;p

  1. Pingback: Apakah Itu Android | 1go123.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s