Pages

How to Write Hello World First Kotlin App



AndroidManifest.xml

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




main.xml 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
> 
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/hello" android:contentDescription="Hello World I'm running Kotlin!"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Kotlin M2 Candidate"
/>
</LinearLayout>



KotlinActivity  

package com.example
import android.app.Activity
import android.os.Bundle

class HelloKotlin() : Activity() {

protected override fun onCreate(savedInstanceState : Bundle?) {
super<Activity>.onCreate(savedInstanceState)
setContentView(R.layout.main)

}
}

Raj

Hello I am Dharmendra Kumar Mishra From Siwan Bihar. I am Android Application Developer and Blogger. I love to share my knowledge over Internet.

No comments: