XML-
BASE PROGRAM
OBJECTIVE
Main.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:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textSize="30dp"
android:textColor="@color/Blue"/>
</LinearLayout>
String.xml
<?xml
version="1.0"
encoding="utf-8"?>
<resources>
<string
name="hello">Wellcome
to Android first-Example</string>
<string
name="app_name">Helloxmlbase</string>
<color
name="Blue">#0000FF</color>
</resources>
HelloxmlbaseActivity.java
package
com.android.hello;
import
android.app.Activity;
import
android.os.Bundle;
public
class
HelloxmlbaseActivity extends
Activity {
/**
Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
AndroidManifest.java
<?xml
version="1.0"
encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.hello"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8"
/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity
android:name=".HelloxmlbaseActivity"
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>
JAVA-BASE
PROGRAM
JavabaseActivity.java
package
com.android.Hello1;
import
android.app.Activity;
import
android.graphics.Color;
import
android.os.Bundle;
import
android.widget.TextView;
public
class JavabaseActivity extends Activity {
/**
Called when the activity is first created. */
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
TextView
tv=new TextView(this);
tv.setText("Welcome
to Android First-Example");
tv.setTextSize(30);
tv.setTextColor(Color.BLUE);
setContentView(tv);
}
}
AndroidManifest.xml
<?xml
version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.Hello1"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity
android:label="@string/app_name"
android:name="JavabaseActivity"
>
<intent-filter >
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
HYBRID-BASE
EXAMPLE
String.xml
<?xml
version="1.0" encoding="utf-8"?>
<resources>
<string
name="app_name">Hello2</string>
<string
name="hello">Welcome to Android First-Example</string>
<color
name="Blue">#FFFFFF</color>
</resources>
Main.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:orientation="vertical"
>
<TextView
android:id="@+id/TextV1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textSize="30dp"
android:textColor="@color/Blue"/>
</LinearLayout>
Hello2Activity.java
package
com.android.Hello2;
import
android.app.Activity;
import
android.os.Bundle;
import
android.widget.TextView;
public
class Hello2Activity extends Activity {
/**
Called when the activity is first created. */
TextView
tv;
@Override
public
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.TextV1);
tv.setText("This
is modified Text");
tv.setTextSize(33);
}
}
<?xml
version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.Hello2"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk
android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity
android:label="@string/app_name"
android:name=".Hello2Activity"
>
<intent-filter >
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
No comments:
Post a Comment