CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren 2015-2016 SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren 2015-2016.

Slides:



Advertisements
Similar presentations
Client / Server Programming in Android Eclipse IDE Android Development Tools (ADT) Android SDK
Advertisements

Basic, Basic, Basic Android. What are Packages? Page 346 in text Package statement goes before any import statements Indicates that the class declared.
Android Application Development with Java UPenn CS4HS 2011 Chris Murphy
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Android - Broadcast Receivers
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Google map v2.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Mobile Software Development for Android - I397
Lab7 – Appendix.
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android N Amanquah.
several communicating screens
Adapting to Display Orientation
GUI Programming Fundamentals
Android Introduction Hello World.
Android Dr. Vaishali D. Khairnar IT Department
Android Widgets 1 7 August 2018
ITEC535 – Mobile Programming
Android – Read/Write to External Storage
Mobile Device Development
Android App Computations
Picasso Revisted.
CIS 470 Mobile App Development
CS323 Android Model-View-Controller Architecture
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
HNDIT2417 Mobile Application Development
CIS 470 Mobile App Development
Programski jezici za mobilne aplikacije
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
Adding Components to Activity
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Chapter 5 Your Second Activity.
Activities, Fragments, and Intents
CIS 470 Mobile App Development
Mobile Programming Broadcast Receivers.
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department CMPE419 AU

Adding New Page and Button, EditText, TextView

How to add a new page to the existing project? package com.example.buttonw; import android.app.Activity; import android.os.Bundle; public class ButtonMainActivity extends Activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_button_main); } ButtonMainActivity.java

<RelativeLayout xmlns:android=" /android" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${relativePackage}.${activityClass}" > Activity_button_main.xml

For creating a new page : right click to layout directory and select from New-Other-Android- Android XML File

Now we have to create Java Controller file for newpage.xml For this create a class under scr directory.

package com.example.buttonw; public class NewActivity { } Modify this class as an activity class: package com.example.buttonw; import android.app.Activity; public class NewActivity extends Activity{ }

We have to add onCreate() and setContentView to the NewActivity.java file.

package com.example.buttonw; import android.app.Activity; import android.os.Bundle; public class NewActivity extends protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } Now we have to connect our Java class to xml file by using setContentView setContentView(R.layout.newpage);

package com.example.buttonw; import android.app.Activity; import android.os.Bundle; public class NewActivity extends protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.newpage); } Now we have to modify Manifest file.

AndroidManifest.xml <manifest xmlns:android=" package="com.example.buttonw" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" > <activity android:name=".ButtonMainActivity" >

For the new activity we have to add the following code to the AndroidManifest.xml file: <activity android:name=".NewActivity" >

<manifest xmlns:android=" package="com.example.buttonw" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <application android:allowBackup="true" > <activity android:name=".ButtonMainActivity" > <activity android:name=".NewActivity" > DEFAULT for all other activities

Button, EditView and TextView TextView  is a label for displaying text EditView  is a textbox for entering a text Lets add a Button, an EditView and a TextView to the main activity.

Now lets enter a text and display it after pressing a button. For this we have to use Java code and create appropreate objects.

<RelativeLayout xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="${relativePackage}.${activityClass}" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="62dp" android:text="TextView" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="78dp" android:ems="10" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="60dp" android:text="Button" />

package com.example.buttonw; 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 ButtonMainActivity extends Activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_button_main); final TextView show=(TextView)findViewById(R.id.textView1); show.setText(""); final EditText all=(EditText)findViewById(R.id.editText1); Button b=(Button)findViewById(R.id.button1); b.setText("Display"); b.setOnClickListener(new View.OnClickListener() public void onClick(View v) { // TODO Auto-generated method stub show.setText(all.getText()); } }); }

How to jump new activity? Create a New Button Use this button to jump to new acctivity. Button bb=(Button)findViewById(R.id.button2); bb.setOnClickListener(new View.OnClickListener() public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent("android.intent.action.NEW")); } }); }