Monday, 6 June 2011

Task Manager Activity.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:id="@+id/tasks_title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/tasks"
    />
    <TextView
    android:id="@+id/tasks_list_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/tasks_title"
    android:layout_above="@+id/add_button" />
    <Botton
    android:id="@id/add_button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/add_task"
    android:layout_alignParentBottom="true"
    />
</RelativeLayout>



string.xml



<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">My Task Manager</string>
    <string name="tasks">Tasks</string>
    <string name="add_task">ADD Task</string>
</resources>


ViewTaskActivity.java



package com.seyi.android.mytaskmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ViewTaskActivity extends Activity {
   
    private Button addButton;
private TextView taskText;

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setUpViews();
    }

private void setUpViews() {

addButton=(Button)findViewById(R.id.add_button);
taskText=(TextView)findViewById(R.id.tasks_list_text);
addButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent(ViewTaskActivity.this,AddTaskActivity.class);
startActivity(intent);
}

});
}
}



AddTaskActivity.java



package com.seyi.android.mytaskmanager;

import android.app.Activity;
import android.os.Bundle;

public class AddTaskActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.add_task);
}

}

add_task.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"
    >
    </LinearLayout>

My Task Manager Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.seyi.android.mytaskmanager"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".ViewTaskActivity"
                  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=".ViewTaskActivity"
                  android:label="@string/app_name">
                  </activity>
                  
    </application>
</manifest>


No comments:

Post a Comment