Dasar Pemrograman Android

1.    Hello World

Source : CobaActivity.java

package ini.saja;

import android.app.Activity;

import android.os.Bundle;

public class CobaActivity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

}

Running program :

Image

2.    Menambahkan Image

Source : main.xml

<?xml version=“1.0” encoding=“utf-8″?>

<LinearLayoutxmlns:android=http://schemas.android.com/apk/res/android&#8221;

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

android:orientation=“vertical” >

<TextView

android:layout_width=“fill_parent”

android:layout_height=“wrap_content”

android:text=“@string/hello” />

<ImageView

android:id=“@+id/imageView1″

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:src=“@drawable/ic_launcher” />

</LinearLayout> 

Hasil running :

 Image

About these ads

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