coding mobile programing (dasar)
Coding Pemograman
Android
<?xml version="1.0"
encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentleft="true"
android:text="Bang Purba
1" />
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:text="Bang Purba
2"/>
<TextView
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentleft="true"
android:text="Bang Purba
3" />
<TextView
android:id="@+id/t4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Bang Purba
4"/>
<TextView
android:id="@+id/t5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Bang Purba
5"/>
</RelativeLayout>
hasil tampilan coding diatas!!
Adapun
program lainnya :
MODUL BELAJAR
MOBILE PROGRAMING
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TIB5_Activity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="36dp"
android:text="INPUT
1"
/>
<EditText
android:id="@+id/input1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_marginLeft="17dp"
android:layout_toRightOf="@+id/textView1"
android:ems="10"
android:inputType="number"
/>
<TextView
android:id="@+id/hasil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/btnHitung"
android:layout_below="@+id/input1"
android:layout_marginTop="108dp"
android:text="hasil"
android:textStyle="bold"
/>
<EditText
android:id="@+id/input2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/input1"
android:layout_below="@+id/input1"
android:layout_marginTop="37dp"
android:ems="10"
android:inputType="number"
>
</EditText>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/input2"
android:layout_toLeftOf="@+id/input1"
android:text="INPUT 2"
/>
<Button
android:id="@+id/btnReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/input2"
android:layout_below="@+id/hasil"
android:layout_marginRight="16dp"
android:layout_marginTop="54dp"
android:text="RESET"
/>
<Button
android:id="@+id/btnHitung"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnReset"
android:layout_alignBottom="@+id/btnReset"
android:layout_alignLeft="@+id/textView2"
android:text="HITUNG"
/>
</RelativeLayout>
TIB5_VARIABEL
package TIB5.variabel;
import
android.app.Activity;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.Button;
import
android.widget.EditText;
import android.widget.TextView;
public class
TIB5_variabelActivity extends Activity {
/** Called when the activity is first
created. */
EditText
input1,input2;
TextView
hasil;
Button
tampil,reset;
int x,y,hitung;
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
input1 = (EditText) findViewById(R.id.input1);
input2 = (EditText) findViewById(R.id.input2);
hasil = (TextView)
findViewById(R.id.hasil);
tampil = (Button) findViewById(R.id.btnHitung);
reset = (Button) findViewById(R.id.btnReset);
tampil.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v)
{
// TODO Auto-generated
method stub
x = Integer.parseInt(input1.getText().toString());
y = Integer.parseInt(input2.getText().toString());
hitung = x+y;
hasil.setText("Hasil :" + hitung);
reset.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v)
{
// TODO
Auto-generated method stub
input1.setText("0");
input2.setText("0");
hasil.setText("Hasil :0");
}
});
}
});
}
}
Komentar
Posting Komentar